Skip to content

Configure the AI Agent

These three variables cover most deployments.

VariableDefaultPurpose
LLM_API_KEYProvider API key. Required to enable the agent.
LLM_API_BASEhttps://openrouter.ai/api/v1OpenAI-compatible base URL.
LLM_MODELopenrouter:openrouter/freeModel identifier (provider:modelId).
Terminal window
LLM_API_KEY=sk-or-...
LLM_API_BASE=https://openrouter.ai/api/v1
LLM_MODEL=openrouter:openrouter/auto

Set the key for each provider you want to use. Only providers with a key configured appear as selectable in the model picker.

VariableProviderNotes
OPENROUTER_API_KEYOpenRouterAlias for LLM_API_KEY when using OpenRouter.
OPENROUTER_API_BASEOpenRouterOverride base URL.
OPENROUTER_REFEREROpenRouterHTTP referer sent with requests (for leaderboard attribution).
OPENROUTER_APP_NAMEOpenRouterApp name sent with requests.
OPENROUTER_MODELS_APIOpenRouterOverride models list URL.
NVIDIA_API_KEYNVIDIA NIMNIM API key.
NVIDIA_API_BASENVIDIA NIMNIM base URL (defaults to NVIDIA’s hosted endpoint).
ANYROUTER_API_KEYAnyRouterAnyRouter API key.
ANYROUTER_API_BASEAnyRouterAnyRouter base URL.

LLM_EXTRA_MODELS adds entries to the model picker without touching code. Format:

provider:modelId[|contextLength][|description]
  • provider — one of openrouter, nvidia, anyrouter
  • modelId — model ID passed to the provider (may contain colons)
  • contextLength — optional integer token count; defaults to 128000
  • description — optional display label; defaults to modelId

Comma-separated for multiple models:

Terminal window
LLM_EXTRA_MODELS="nvidia:meta/llama-3.3-70b|131072|Llama 3.3 70B,openrouter:x-ai/grok-2"

Extra models are appended after the built-in registry. If an extra entry shares a provider:modelId key with a built-in, the built-in wins.

VariableDefaultPurpose
CHM_FEATURE_AGENT_ACCESSpublicSet to authenticated to require login before using the agent.
AGENT_API_TOKENShared Bearer token accepted by POST /api/v1/agent.
AGENT_ENABLE_CONTROL_TOOLSfalseWhen true, enables optimize_table, kill_query, and kill_mutation. Keep off unless the ClickHouse user is trusted.

Require auth on public deployments:

Terminal window
CHM_FEATURE_AGENT_ACCESS=authenticated

Protect the API endpoint with a bearer token:

Terminal window
AGENT_API_TOKEN=your-secret-token
Terminal window
curl -H "Authorization: Bearer $AGENT_API_TOKEN" \
-d '{"message":"...","hostId":0}' \
https://your-host/api/v1/agent
VariableTypeDefaultPurpose
VITE_FEATURE_CONVERSATION_DBBuild-timefalseEnable server-side conversation storage. Must be set before bun run build. Requires Clerk.
CONVERSATION_STORE_BACKENDRuntime(auto)Backend: agentstate, d1, postgres, or memory. Auto-selects when unset.

See Conversation History and Store Backends for per-backend env vars and setup.

  • Cloudflare Workerswrangler secret put LLM_API_KEY for secrets; [vars] in wrangler.toml for non-secret values. See Deploy to Cloudflare.
  • Dockerenvironment: block in docker-compose.yml or --env-file .env. See Deploy with Docker.
  • KubernetesSecret for keys, ConfigMap for non-secret values. See Deploy to Kubernetes.
  • Vercel / self-hosted — environment variables in the project dashboard or .env.local.