Skip to content

Environment Variables

llmist uses environment variables for provider authentication and configuration.

Set these environment variables to enable provider auto-discovery:

Terminal window
# OpenAI
export OPENAI_API_KEY="sk-..."
# Anthropic
export ANTHROPIC_API_KEY="sk-ant-..."
# Google Gemini
export GEMINI_API_KEY="..."
# OpenRouter (400+ models via unified gateway)
export OPENROUTER_API_KEY="sk-or-..."

When you create an agent without specifying a provider, llmist:

  1. Checks for API keys in environment variables
  2. Registers providers with valid keys
  3. Selects the appropriate provider based on model name
// Auto-discovers providers from environment
const agent = LLMist.createAgent()
.withModel('sonnet'); // Uses Anthropic if ANTHROPIC_API_KEY is set
VariableDescriptionValues
LLMIST_LOG_LEVELLogging verbositysilly, trace, debug, info, warn, error, fatal
Terminal window
# Enable debug logging
export LLMIST_LOG_LEVEL="debug"

These can also be set via command-line flags:

FlagEnvironment VariableDescription
--log-levelLLMIST_LOG_LEVELSet log level
Terminal window
# Via flag
npx @llmist/cli agent "Hello" --log-level debug
# Via environment
LLMIST_LOG_LEVEL=debug npx @llmist/cli agent "Hello"
VariableDescription
OPENAI_API_KEYAPI key (required)
OPENAI_ORG_IDOrganization ID (optional)
OPENAI_BASE_URLCustom API endpoint (optional)
VariableDescription
ANTHROPIC_API_KEYAPI key (required)
ANTHROPIC_BASE_URLCustom API endpoint (optional)
VariableDescription
GEMINI_API_KEYAPI key (required)
VariableDescription
OPENROUTER_API_KEYAPI key (required)
OPENROUTER_SITE_URLYour app URL for analytics (optional)
OPENROUTER_APP_NAMEYour app name for analytics (optional)
  1. Never commit API keys - Use .env files or secret managers
  2. Use different keys per environment - Separate dev/staging/production
  3. Rotate keys regularly - Update keys periodically for security
Terminal window
# .env (add to .gitignore!)
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...

Load with your preferred method:

  • Node.js: dotenv package
  • Bun: Built-in .env support
  • Shell: source .env or export $(cat .env | xargs)