Environment Variables
Full catalog of Anvio environment variables, organized by category, grounded in .env.example.
7 min read
Anvio needs zero environment variables to start at Level 1 — anvio chat runs in mock mode without any key. Everything below is opt-in, organized by what it unlocks. The authoritative source is .env.example at the repo root; copy it to .env and uncomment what you need.
Level 1–2 workspaces typically only set ANVIO_WORKSPACE and one model provider key (or nothing, for mock mode). The database/events/observability sections below only apply once you opt into Level 2–4 deployment (see Docker and the deployment levels table).
Workspace
| Variable | Default | Description |
|---|---|---|
ANVIO_WORKSPACE | ./workspace | Root path for the file-first workspace (souls, agents, memory, sessions, credentials). |
Model provider keys (direct API access)
These power the local runtime — the built-in model + tool loop. This is a different auth layer from runtime OAuth below; see Authentication for the distinction.
| Variable | Notes |
|---|---|
ANTHROPIC_API_KEY | Optional — omit entirely to run in mock mode. |
OPENAI_API_KEY | |
GEMINI_API_KEY / GOOGLE_API_KEY | Either name is accepted for Gemini. |
OPENROUTER_API_KEY | |
OPENROUTER_REFERER | Sent as HTTP-Referer header to OpenRouter. |
OPENROUTER_APP_NAME | Sent as X-Title header to OpenRouter. |
DEEPSEEK_API_KEY | OpenAI-compatible provider. |
GROQ_API_KEY | OpenAI-compatible provider. |
MISTRAL_API_KEY | OpenAI-compatible provider. |
TOGETHER_API_KEY | OpenAI-compatible provider. |
XAI_API_KEY | OpenAI-compatible provider. |
FIREWORKS_API_KEY | OpenAI-compatible provider. |
MOONSHOT_API_KEY | OpenAI-compatible provider. |
CEREBRAS_API_KEY | OpenAI-compatible provider. |
SAMBANOVA_API_KEY | OpenAI-compatible provider. |
PERPLEXITY_API_KEY | OpenAI-compatible provider. |
COHERE_API_KEY | OpenAI-compatible provider. |
OLLAMA_BASE_URL | Default http://127.0.0.1:11434. |
OLLAMA_ENABLED | Set true to enable local Ollama routing. |
CUSTOM_API_KEY | For a custom OpenAI-compatible endpoint; pair with provider: custom in agent YAML. |
Set only the ones you use — Anvio routes per-agent based on agent.spec.model.provider, not a single global provider.
Runtime OAuth (vendor CLI subscriptions)
These authenticate external runtime providers (Claude Code, Cursor, Codex, Antigravity) via the vendor's own CLI/app OAuth flow. This is entirely separate from the model API keys above — see Runtime OAuth for the full model. Provisioned by anvio setup-token, not typed in by hand.
| Variable | Vendor | Notes |
|---|---|---|
CLAUDE_CODE_OAUTH_TOKEN | Claude Code | Produced by anvio setup-token --claude. Pro/Max subscription quota, not API billing. |
ANTIGRAVITY_TOKEN | Antigravity CLI | Produced by anvio setup-token --antigravity. Google Sign-In, not GEMINI_API_KEY. |
CODEX_ACCESS_TOKEN | OpenAI Codex CLI | Produced by anvio setup-token --codex. ChatGPT subscription, not OPENAI_API_KEY. |
Never set ANTHROPIC_API_KEY in the same environment as an active claude-code runtime unless you intend local as an explicit fallback. The Claude Agent SDK subprocess must not see ANTHROPIC_API_KEY when OAuth mode is active — an API key shadows OAuth and bills API credits instead of subscription quota.
Encryption / auth
| Variable | Used by | Notes |
|---|---|---|
ANVIO_CREDENTIALS_PASSPHRASE | packages/credentials (EncryptedCredentialStore) | Passphrase for AES-256-GCM encryption of API keys stored via anvio credentials add. Change in production. |
ANVIO_CONNECTION_ENCRYPTION_KEY | packages/harness connection broker | Encrypts OAuth tokens / connection payloads stored under workspace/connections/_state/. Required when connectBroker.enabled: true in workspace/harness/defaults.yaml. |
JWT_SECRET | @anvio/auth (JwtAuthProvider) | Only meaningful when workspace/anvio.yaml sets auth.enabled: true and auth.provider: jwt. Change in production. |
GITHUB_TOKEN | MCP integrations | Optional — enables GitHub-backed MCP servers configured in workspace/mcp/servers.yaml. |
Never commit .env, ANVIO_CONNECTION_ENCRYPTION_KEY, ANVIO_CREDENTIALS_PASSPHRASE, or any OAuth token to git. Rotating the connection encryption key makes existing encrypted connection blobs permanently unreadable — plan rotations as a migration. See Secrets & Encryption.
API / gateway ports (Level 2+)
| Variable | Default | Service |
|---|---|---|
API_PORT | 3000 | @anvio/api listen port |
GATEWAY_PORT | 3001 | @anvio/gateway listen port |
API_URL | http://localhost:3000 | Used by the gateway to reach the API |
ACP_PORT | 8765 | Optional — ACP editor integration server |
Database / services (Level 3+)
| Variable | Default | Notes |
|---|---|---|
DATABASE_URL | — | postgresql://anvio:anvio@localhost:5432/anvio in Docker Compose. Required only once storage.provider: postgres (or higher) is set. |
REDIS_URL | — | redis://localhost:6379. Required for cache/session state at Level 3. |
NATS_URL | — | nats://localhost:4222. Required when events.provider: nats in anvio.yaml. |
In docker/docker-compose.yml, these are constructed automatically from POSTGRES_USER / POSTGRES_PASSWORD / POSTGRES_DB and internal service hostnames — you don't set DATABASE_URL directly when using that compose file.
Observability
| Variable | Notes |
|---|---|
OTEL_EXPORTER_OTLP_ENDPOINT | e.g. http://localhost:4318 for a local collector, or https://cloud.langfuse.com/api/public/otel for Langfuse Cloud. Setting this alone enables OTel export. |
OTEL_SERVICE_NAME | Reported service name in spans (e.g. anvio). |
OTEL_TRACES_EXPORTER / OTEL_METRICS_EXPORTER | Set to otlp. |
OTEL_EXPORTER_OTLP_HEADERS | e.g. Authorization=Basic <base64 pk:sk> for Langfuse auth. |
ANVIO_OTEL_ENABLED | Explicit boolean override; initObservability() also auto-enables when OTEL_EXPORTER_OTLP_ENDPOINT is set. |
See Tracing for the full OTLP + Langfuse setup.
Channel-specific OAuth / tokens
Read directly from packages/channels/src/create-channels.ts and channel-health.ts (not present in .env.example — set these when enabling the corresponding channel):
| Variable | Channel | Notes |
|---|---|---|
SLACK_BOT_TOKEN | Slack | Bot token (xoxb-...). |
SLACK_APP_TOKEN | Slack | App-level token (xapp-...) for Socket Mode. |
TELEGRAM_BOT_TOKEN | Telegram | From BotFather. |
DISCORD_BOT_TOKEN | Discord | Bot token; also used by the Discord niche tool in packages/tools/src/builtins/niche-tools.ts. |
WHATSAPP_ACCESS_TOKEN | Cloud API access token. | |
WHATSAPP_PHONE_NUMBER_ID | Cloud API phone number ID. | |
WHATSAPP_VERIFY_TOKEN | Webhook verify token; defaults to anvio-verify if unset. |
All of the above can alternatively be set per-channel in workspace config (options.channels.slack.botToken, etc.) instead of environment variables — env vars are the fallback when config is absent.
TODO: Signal, Google Chat, Teams, Matrix, Feishu, and SMS (Twilio) channels also require credentials per the P12–P14 phase docs and the gap register, but their exact env var names were not confirmed against source in this pass. Check
packages/channels/srcfor the authoritative names before deploying those channels.
Dev / testing mocks
Several integrations support a _MOCK=1 escape hatch so CI and local dev can exercise code paths without live vendor credentials. Referenced in CHANGELOG.md and the gap register:
| Variable | Unlocks mock mode for |
|---|---|
ANVIO_NOUS_MOCK | Nous Portal OAuth / tools |
ANVIO_SINGULARITY_MOCK | Singularity/Apptainer runtime exec |
ANVIO_ATROPOS_MOCK | Atropos RL training tool (rl_tool) |
ANVIO_YUANBAO_MOCK | Yuanbao tool bundle (yb_tool) |
ANVIO_VIDEO_MOCK | video_generate MCP preset |
ANVIO_HONCHO_MOCK | Honcho memory tool bundle (honcho_tool) |
ANVIO_BROWSER_CDP_GRANT | Opt-in extended raw browser_cdp methods (=1) |
CI itself (.github/workflows/ci.yml) sets plain placeholder values for the test job: ANTHROPIC_API_KEY: test-key, JWT_SECRET: test-secret, plus live postgres/redis/nats service containers — see CI/CD.
Full reference (.env.example)
# Anvio Local Environment (Optional — Level 1 needs none of this)
# Workspace path (default: ./workspace)
ANVIO_WORKSPACE=./workspace
# Model provider (optional — mock mode without any key)
ANTHROPIC_API_KEY=sk-ant-your-key-here
# Claude Code runtime OAuth (Pro/Max subscription — not API key billing)
# anvio setup-token --claude
# CLAUDE_CODE_OAUTH_TOKEN=sk-ant-oat01-your-token-here
# Antigravity CLI runtime OAuth (Google Sign-In — not GEMINI_API_KEY)
# anvio setup-token --antigravity
# ANTIGRAVITY_TOKEN=your-token-here
# Codex CLI runtime OAuth (ChatGPT subscription — not OPENAI_API_KEY for codex runtime)
# anvio setup-token --codex
# CODEX_ACCESS_TOKEN=your-token-here
# OPENAI_API_KEY=sk-your-key-here
# GEMINI_API_KEY=your-gemini-key
# GOOGLE_API_KEY=your-gemini-key
# OPENROUTER_API_KEY=sk-or-your-key-here
# OPENROUTER_REFERER=https://your-app.example
# OPENROUTER_APP_NAME=Anvio
# OpenAI-compatible providers (set any that you use)
# DEEPSEEK_API_KEY=sk-your-key-here
# GROQ_API_KEY=gsk_your-key-here
# MISTRAL_API_KEY=your-key-here
# TOGETHER_API_KEY=your-key-here
# XAI_API_KEY=your-key-here
# FIREWORKS_API_KEY=your-key-here
# MOONSHOT_API_KEY=your-key-here
# CEREBRAS_API_KEY=your-key-here
# SAMBANOVA_API_KEY=your-key-here
# PERPLEXITY_API_KEY=pplx-your-key-here
# COHERE_API_KEY=your-key-here
# OLLAMA_BASE_URL=http://127.0.0.1:11434
# OLLAMA_ENABLED=true
# Custom OpenAI-compatible endpoint (use with provider: custom in agent YAML)
# CUSTOM_API_KEY=your-key-here
# Credential pools (Advanced OS — optional)
# Used when storing encrypted API keys via `anvio credentials add`
ANVIO_CREDENTIALS_PASSPHRASE=change-me-in-production
# MCP integrations (optional — enable servers in workspace/mcp/servers.yaml)
# GITHUB_TOKEN=ghp_your-token-here
# --- Level 2+ only ---
# API
API_PORT=3000
# Gateway
GATEWAY_PORT=3001
API_URL=http://localhost:3000
# ACP editor integration (optional)
# ACP_PORT=8765
# Auth (only when workspace/anvio.yaml has auth.enabled: true)
JWT_SECRET=change-me-in-production
# PostgreSQL (Level 3 — optional)
# DATABASE_URL=postgresql://anvio:anvio@localhost:5432/anvio
# Redis (Level 3 — optional)
# REDIS_URL=redis://localhost:6379
# NATS (Level 3 — set events.provider: nats in anvio.yaml)
# NATS_URL=nats://localhost:4222
# Observability (optional)
# OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318Last updated on