Skip to main content

Configuration

vai resolves configuration from multiple sources, in this priority order:

  1. CLI flags (highest priority)
  2. Environment variables
  3. .env file in the current directory
  4. ~/.vai/config.json (persistent config store)
  5. .vai.json project config (defaults)

Environment Variables

VariableRequired ForDescription
VOYAGE_API_KEYAll embedding/rerankingAPI key from MongoDB Atlas
MONGODB_URIstore, search, query, pipeline, indexMongoDB Atlas connection string
VAI_DEFAULT_DBOptionalDefault database name
VAI_DEFAULT_COLLECTIONOptionalDefault collection name
VAI_LLM_PROVIDERchatLLM provider: anthropic, openai, or ollama
VAI_LLM_API_KEYchat (cloud)API key for the LLM provider
VAI_LLM_MODELchatModel name (e.g., claude-sonnet-4-20250514, gpt-4o)
VAI_LLM_BASE_URLchat (ollama)Ollama base URL (default: http://localhost:11434)
VAI_CHAT_HISTORYchatEnable chat history persistence (true/false)
VAI_CHAT_HISTORY_DBchatDatabase for chat history storage
VAI_CHAT_MAX_DOCSchatMax documents to retrieve per query
VAI_CHAT_MAX_TURNSchatMax conversation turns to include as context
VAI_MCP_VERBOSEmcpEnable verbose MCP server logging
VAI_MCP_SERVER_KEYmcp (HTTP)Bearer token for HTTP transport authentication

Config Store

The built-in config store persists values across sessions:

# Set values
vai config set api-key "your-voyage-key"
vai config set mongodb-uri "mongodb+srv://..."

# Read from stdin (avoids key in shell history)
echo "your-key" | vai config set api-key --stdin

# Get a value (secrets are masked)
vai config get api-key

# Get all config values
vai config get

# Delete a value
vai config delete api-key

# Show config file path
vai config path

# Reset everything
vai config reset

Config is stored at ~/.vai/config.json. Sensitive values are masked when displayed.

All Config Keys

KeyDescriptionExample
api-keyVoyage AI API keyvai config set api-key pa-...
mongodb-uriMongoDB Atlas connection stringvai config set mongodb-uri "mongodb+srv://..."
base-urlOverride API endpointvai config set base-url https://ai.mongodb.com/v1
default-modelDefault embedding modelvai config set default-model voyage-3
default-dimensionsDefault output dimensionsvai config set default-dimensions 512
default-dbDefault MongoDB databasevai config set default-db my_knowledge_base
default-collectionDefault MongoDB collectionvai config set default-collection documents
llm-providerLLM provider (anthropic, openai, ollama)vai config set llm-provider anthropic
llm-api-keyLLM provider API keyvai config set llm-api-key sk-...
llm-modelLLM model overridevai config set llm-model claude-sonnet-4-5-20250929
llm-base-urlLLM endpoint overridevai config set llm-base-url http://localhost:11434
show-costShow cost estimates after operationsvai config set show-cost true
telemetryAnonymous usage telemetryvai config set telemetry false

The default-db and default-collection keys are particularly useful — set them once and all workflows, vai query, vai store, and other database commands use them automatically. The desktop app's Settings → Database page also reads and writes these values.

Credential Resolution

When vai needs a credential (like VOYAGE_API_KEY), it checks sources in order:

CLI flag → Environment variable → .env file → ~/.vai/config.json

The first non-empty value wins. This means you can set project-specific credentials in .env files and fall back to global credentials in the config store.

Next Steps