|
| 1 | +--- |
| 2 | +sidebar_position: 6 |
| 3 | +--- |
| 4 | + |
| 5 | +# Configuration |
| 6 | + |
| 7 | +This guide covers the configuration options available in Eliza. |
| 8 | + |
| 9 | +> **Note:** Requires Node.js 20+ |
| 10 | +
|
| 11 | +## Initial Setup |
| 12 | +- Copy .env.example to .env and fill in the appropriate values |
| 13 | +- Edit the TWITTER environment variables to add your bot's username and password |
| 14 | + |
| 15 | +### Linux Installation |
| 16 | + |
| 17 | +You might need these |
| 18 | + |
| 19 | +```bash |
| 20 | +pnpm install --include=optional sharp |
| 21 | +``` |
| 22 | + |
| 23 | +## Environment Variables |
| 24 | + |
| 25 | +### Model Provider Tokens |
| 26 | +```bash |
| 27 | +# Required - At least one model provider |
| 28 | +OPENAI_API_KEY="sk-*" # OpenAI API key |
| 29 | +ANTHROPIC_API_KEY="sk-*" # Claude API key (optional) |
| 30 | + |
| 31 | +# Model Selection |
| 32 | +XAI_MODEL="gpt-4o-mini" # Model selection |
| 33 | +# Available options: |
| 34 | +XAI_MODEL=gpt-4o # OpenAI GPT-4 Turbo |
| 35 | +XAI_MODEL=gpt-4o-mini # OpenAI GPT-4 |
| 36 | +XAI_MODEL=meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo # Llama 70B |
| 37 | +XAI_MODEL=meta-llama/Meta-Llama-3.1-405B-Instruct # Llama 405B |
| 38 | +XAI_MODEL=grok-beta # Grok |
| 39 | + |
| 40 | +### Platform Integration |
| 41 | +# Required for each enabled client |
| 42 | +DISCORD_TOKEN="your-discord-token" |
| 43 | +TELEGRAM_BOT_TOKEN="your-telegram-token" |
| 44 | +TWITTER_USERNAME="your-twitter-username" |
| 45 | +TWITTER_PASSWORD="your-twitter-password" |
| 46 | + |
| 47 | +### Optional Features |
| 48 | +# Voice Support |
| 49 | +ELEVENLABS_XI_API_KEY="your-elevenlabs-key" |
| 50 | +ELEVENLABS_MODEL_ID="eleven_multilingual_v2" |
| 51 | +ELEVENLABS_VOICE_ID="21m00Tcm4TlvDq8ikWAM" |
| 52 | +ELEVENLABS_VOICE_STABILITY=0.5 |
| 53 | +ELEVENLABS_VOICE_SIMILARITY_BOOST=0.9 |
| 54 | +ELEVENLABS_VOICE_STYLE=0.66 |
| 55 | +ELEVENLABS_VOICE_USE_SPEAKER_BOOST=false |
| 56 | +ELEVENLABS_OPTIMIZE_STREAMING_LATENCY=4 |
| 57 | +ELEVENLABS_OUTPUT_FORMAT=pcm_16000 |
| 58 | + |
| 59 | +# Local AI Support |
| 60 | +LOCALAI_URL="http://localhost:8080" |
| 61 | +LOCALAI_TOKEN="your-token" |
| 62 | +``` |
| 63 | + |
| 64 | +## Runtime Configuration |
| 65 | + |
| 66 | +Initialize a runtime with: |
| 67 | + |
| 68 | +```typescript |
| 69 | +import { createAgentRuntime, Database } from "eliza"; |
| 70 | +import { initializeDatabase, ModelProvider } from "eliza"; |
| 71 | + |
| 72 | +// Initialize database |
| 73 | +const db = initializeDatabase(); // Uses SQLite by default |
| 74 | + |
| 75 | +// Get token for model provider (supports character-specific keys) |
| 76 | +const token = getTokenForProvider(ModelProvider.OPENAI, character); |
| 77 | + |
| 78 | +// Create runtime with default configuration |
| 79 | +const runtime = await createAgentRuntime( |
| 80 | + character, |
| 81 | + db, |
| 82 | + token, |
| 83 | + "./elizaConfig.yaml" // Optional, defaults to this path |
| 84 | +); |
| 85 | +``` |
| 86 | + |
| 87 | +The runtime configuration includes: |
| 88 | +- Database adapter (SQLite/PostgreSQL/Supabase) |
| 89 | +- Model provider token |
| 90 | +- Character configuration |
| 91 | +- Built-in providers: |
| 92 | + - timeProvider |
| 93 | + - boredomProvider |
| 94 | +- Default actions: |
| 95 | + - All default actions |
| 96 | + - followRoom/unfollowRoom |
| 97 | + - muteRoom/unmuteRoom |
| 98 | + - imageGeneration |
| 99 | +- Custom actions from elizaConfig.yaml |
| 100 | +- Optional evaluators |
| 101 | + |
| 102 | +## Database Configuration |
| 103 | + |
| 104 | +Choose between SQLite (development) and PostgreSQL/Supabase (production). |
| 105 | + |
| 106 | +### Environment Variables |
| 107 | +```bash |
| 108 | +Optional - defaults to SQLite |
| 109 | +POSTGRES_URL="postgres://user:pass@host:5432/db" |
| 110 | +SUPABASE_URL="https://your-project.supabase.co" |
| 111 | +SUPABASE_SERVICE_API_KEY="your-service-key" |
| 112 | +``` |
| 113 | + |
| 114 | +### Database Adapters |
| 115 | +```typescript |
| 116 | +// SQLite (default for development) |
| 117 | +import { initializeDatabase } from "eliza"; |
| 118 | +const db = initializeDatabase(); // Creates ./db.sqlite |
| 119 | + |
| 120 | +// PostgreSQL |
| 121 | +const db = new PostgresDatabaseAdapter({ |
| 122 | + connectionString: process.env.POSTGRES_URL |
| 123 | +}); |
| 124 | +// Supabase |
| 125 | +const db = new SupabaseDatabaseAdapter( |
| 126 | + process.env.SUPABASE_URL, |
| 127 | + process.env.SUPABASE_SERVICE_API_KEY |
| 128 | +); |
| 129 | +``` |
| 130 | + |
| 131 | +## Token Providers |
| 132 | + |
| 133 | +Configure model-specific tokens: |
| 134 | + |
| 135 | +```typescript |
| 136 | +const token = getTokenForProvider(ModelProvider.OPENAI, character); |
| 137 | +``` |
| 138 | + |
| 139 | +Tokens can be set in environment variables or character-specific settings: |
| 140 | + |
| 141 | +```json |
| 142 | +{ |
| 143 | + "settings": { |
| 144 | + "secrets": { |
| 145 | + "OPENAI_API_KEY": "character-specific-key", |
| 146 | + "CLAUDE_API_KEY": "character-specific-key" |
| 147 | + } |
| 148 | + } |
| 149 | +} |
| 150 | +``` |
| 151 | + |
| 152 | +## Working with Characters |
| 153 | + |
| 154 | +You can either: |
| 155 | +- Modify the default character in `src/core/defaultCharacter.ts` |
| 156 | +- Create a custom character file: |
| 157 | +```json |
| 158 | +{ |
| 159 | + "name": "character_name", |
| 160 | + "settings": { |
| 161 | + "secrets": { |
| 162 | + "OPENAI_API_KEY": "optional-character-specific-key", |
| 163 | + "CLAUDE_API_KEY": "optional-character-specific-key" |
| 164 | + } |
| 165 | + }, |
| 166 | + "bio": [], |
| 167 | + "lore": [], |
| 168 | + "knowledge": [], |
| 169 | + "messageExamples": [], |
| 170 | + "postExamples": [], |
| 171 | + "topics": [], |
| 172 | + "style": {}, |
| 173 | + "adjectives": [], |
| 174 | + "clients": ["discord", "telegram", "twitter"] |
| 175 | +} |
| 176 | +``` |
| 177 | + |
| 178 | +Load characters: |
| 179 | +```bash |
| 180 | +node --loader ts-node/esm src/index.ts --characters="path/to/your/character.json" |
| 181 | +``` |
| 182 | +## Memory Management |
| 183 | +```typescript |
| 184 | +// Basic document processing |
| 185 | +await runtime.processDocument("path/to/document.pdf"); |
| 186 | +await runtime.processUrl("https://example.com"); |
| 187 | +await runtime.processText("Important information"); |
| 188 | +``` |
| 189 | + |
| 190 | +Use built-in knowledge tools: |
| 191 | +```bash |
| 192 | +npx folder2knowledge <path/to/folder> |
| 193 | +npx knowledge2character <character-file> <knowledge-file> |
| 194 | +``` |
| 195 | + |
| 196 | + |
| 197 | +## Platform Integration |
| 198 | + |
| 199 | +Before initializing clients, ensure: |
| 200 | +1. The desired clients are configured in your character file's `clients` array |
| 201 | +2. Required environment variables are set for each platform: |
| 202 | + - Discord: DISCORD_TOKEN |
| 203 | + - Telegram: TELEGRAM_BOT_TOKEN |
| 204 | + - Twitter: TWITTER_USERNAME and TWITTER_PASSWORD |
| 205 | + |
| 206 | +For help with setting up your Discord Bot, check out: https://discordjs.guide/preparations/setting-up-a-bot-application.html |
| 207 | + |
| 208 | +Initialize all configured clients: |
| 209 | + |
| 210 | + |
| 211 | +```typescript |
| 212 | +import { initializeClients } from "eliza"; |
| 213 | + |
| 214 | +try { |
| 215 | + const clients = await initializeClients(character, runtime); |
| 216 | + prettyConsole.success(`✅ Clients successfully started for character ${character.name}`); |
| 217 | +} catch (error) { |
| 218 | + prettyConsole.error(`❌ Error starting clients for ${character.name}: ${error}`); |
| 219 | +} |
| 220 | +``` |
| 221 | + |
| 222 | +### Client-Specific Error Handling |
| 223 | + |
| 224 | +Each client has built-in error handling: |
| 225 | + |
| 226 | +```typescript |
| 227 | +// Telegram Example |
| 228 | +const botToken = runtime.getSetting("TELEGRAM_BOT_TOKEN"); |
| 229 | +if (!botToken) { |
| 230 | + prettyConsole.error(`❌ Telegram bot token is not set for character ${character.name}`); |
| 231 | + return null; |
| 232 | +} |
| 233 | +try { |
| 234 | + const telegramClient = new Client.TelegramClient(runtime, botToken); |
| 235 | + await telegramClient.start(); |
| 236 | + prettyConsole.success(`✅ Telegram client successfully started for character ${character.name}`); |
| 237 | + return telegramClient; |
| 238 | +} catch (error) { |
| 239 | + prettyConsole.error(`❌ Error creating/starting Telegram client for ${character.name}:`, error); |
| 240 | + return null; |
| 241 | +} |
| 242 | +``` |
| 243 | + |
| 244 | + |
| 245 | +## Runtime Components |
| 246 | + |
| 247 | +The runtime includes these built-in components: |
| 248 | + |
| 249 | +### Actions |
| 250 | +- Default actions from defaultActions |
| 251 | +- followRoom/unfollowRoom |
| 252 | +- muteRoom/unmuteRoom |
| 253 | +- imageGeneration |
| 254 | +- Custom actions from elizaConfig.yaml |
| 255 | + |
| 256 | +### Providers |
| 257 | +- timeProvider |
| 258 | +- boredomProvider |
| 259 | + |
| 260 | +See [Advanced Features](./advanced) for adding custom actions and providers. |
| 261 | + |
| 262 | +## Validation |
| 263 | +```bash |
| 264 | +# Python |
| 265 | +python examples/validate.py |
| 266 | +# JavaScript |
| 267 | +node examples/validate.mjs |
| 268 | +``` |
| 269 | + |
| 270 | +## Development Commands |
| 271 | +```bash |
| 272 | +pnpm run dev # Start the server |
| 273 | +pnpm run shell # Start interactive shell |
| 274 | +``` |
| 275 | + |
| 276 | +## Next Steps |
| 277 | +See the [Advanced Features](./advanced) guide for customizing actions, providers, and more. |
0 commit comments