Learn how to configure agents in elizaOS with environment variables, character files, and runtime settings
ElizaOS agents are configured through a combination of environment variables, character files, and runtime settings. This guide covers all configuration options available.
The .env file controls server, database, and provider settings. See .env.example for all available options.
1
Create Environment File
Copy the example environment file:
cp .env.example .env
2
Configure AI Provider
Set your AI model provider API key:
.env
# OpenAIOPENAI_API_KEY=sk-...# Or use Anthropic ClaudeANTHROPIC_API_KEY=...# Or use Google GeminiGOOGLE_GENERATIVE_AI_API_KEY=...# Or use local OllamaOLLAMA_API_ENDPOINT=http://localhost:11434
3
Configure Server Settings
.env
# Server configurationSERVER_PORT=3000SERVER_HOST=0.0.0.0NODE_ENV=development# Enable/disable web UIELIZA_UI_ENABLE=true# API authentication (optional)ELIZA_SERVER_AUTH_TOKEN=your-secret-token
4
Database Configuration
Choose between PostgreSQL or PGLite:
.env
# PostgreSQL (recommended for production)POSTGRES_URL=postgresql://user:pass@localhost:5432/eliza# Or PGLite (in-memory or file-based)PGLITE_DATA_DIR=.eliza/.elizadb# For in-memory: PGLITE_DATA_DIR=memory://
import { AgentRuntime } from '@elizaos/core';import fs from 'fs';const characterPath = './characters/my-agent.json';const character = JSON.parse(fs.readFileSync(characterPath, 'utf-8'));const runtime = new AgentRuntime({ character, // ... other options});
# Additional channels to always respond inALWAYS_RESPOND_CHANNELS=CUSTOM_CHANNEL_1,CUSTOM_CHANNEL_2# Additional sources to always respond toALWAYS_RESPOND_SOURCES=custom_source,another_source
By default, agents always respond in DM channels, voice DMs, self channels, and API channels. Platform mentions and replies also trigger responses automatically.