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-..."
# HuggingFace (free tier, serverless inference)
export HF_TOKEN="hf_..."

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
Variable Description Values
LLMIST_LOG_LEVEL Logging verbosity silly, trace, debug, info, warn, error, fatal
LLMIST_LOG_FILE Write logs to a file instead of console File path
LLMIST_LOG_RESET Truncate log file on startup true, false
LLMIST_LOG_TEE Also write to stdout when file logging is active true, false
Terminal window
# Enable debug logging
export LLMIST_LOG_LEVEL="debug"
# Log to file AND stdout (useful for Docker/containers)
export LLMIST_LOG_FILE="/tmp/agent.log"
export LLMIST_LOG_TEE="true"

These can also be set via command-line flags:

Flag Environment Variable Description
--log-level LLMIST_LOG_LEVEL Set 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"
Variable Description
OPENAI_API_KEY API key (required)
OPENAI_ORG_ID Organization ID (optional)
OPENAI_BASE_URL Custom API endpoint (optional)
Variable Description
ANTHROPIC_API_KEY API key (required)
ANTHROPIC_BASE_URL Custom API endpoint (optional)
Variable Description
GEMINI_API_KEY API key (required)
Variable Description
OPENROUTER_API_KEY API key (required)
OPENROUTER_SITE_URL Your app URL for analytics (optional)
OPENROUTER_APP_NAME Your app name for analytics (optional)

Access thousands of open-source models via HuggingFace’s serverless inference router.

Variable Description
HF_TOKEN HuggingFace access token (primary, required)
HUGGING_FACE_API_KEY Fallback token if HF_TOKEN is not set (optional)
HF_ENDPOINT_URL Custom inference endpoint URL (optional, for dedicated endpoints)
Terminal window
# Standard serverless inference (router.huggingface.co)
export HF_TOKEN="hf_..."
# Dedicated endpoint (overrides the default router URL)
export HF_TOKEN="hf_..."
export HF_ENDPOINT_URL="https://xxx.endpoints.huggingface.cloud"
  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)