Create your first elizaOS agent with a simple command-line chat interface. This example demonstrates core concepts: runtime initialization, message handling, and streaming responses.
The basic chat example is the quickest way to get started with elizaOS. It creates an agent that responds to user input in real-time through a terminal interface.What you’ll learn:
🚀 Starting Eliza...💬 Chat with Eliza (type 'exit' to quit)You: Hello, how are you?Eliza: Hello! I'm doing well, thank you for asking. How can I help you today?You: What can you do?Eliza: I can help you with various tasks like answering questions, having conversations, providing information, and assisting with problem-solving. What would you like to know more about?You: exit👋 Goodbye!
The character defines your agent’s personality and behavior:
const character: Character = { name: "Eliza", // Agent name bio: "A helpful AI assistant.", // Short description system: "You are friendly...", // System prompt (optional)};
Add more personality by including traits, topics, and style in your character definition.
const runtime = new AgentRuntime({ character, plugins: [sqlPlugin, openaiPlugin], // Add functionality});await runtime.initialize(); // Must call before use
import { anthropicPlugin } from "@elizaos/plugin-anthropic";const runtime = new AgentRuntime({ character, plugins: [sqlPlugin, anthropicPlugin], // Use Claude instead});
import { Action } from "@elizaos/core";const customAction: Action = { name: "GET_TIME", description: "Get the current time", examples: [["What time is it?", "The current time is..."]], handler: async (runtime, message) => { return { text: `The current time is ${new Date().toLocaleTimeString()}`, }; },};runtime.registerAction(customAction);