Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Configuration reference

llmshim reads provider keys from environment variables. The CLI and proxy can also load ~/.llmshim/config.toml, filling only variables that are not already set. Therefore environment variables take precedence over the file.

Provider keys

ProviderEnvironment variableConfig key
OpenAIOPENAI_API_KEYkeys.openai
AnthropicANTHROPIC_API_KEYkeys.anthropic
Google GeminiGEMINI_API_KEYkeys.gemini
xAIXAI_API_KEYkeys.xai

The config file shape is:

[keys]
openai = "..."
anthropic = "..."
gemini = "..."
xai = "..."

[proxy]
host = "0.0.0.0"
port = 3000

Manage it without editing TOML by hand:

llmshim configure
llmshim set anthropic '...'
llmshim get anthropic
llmshim list
llmshim path

Valid set/get keys are openai, anthropic, gemini, xai, proxy.host, and proxy.port. Displayed API keys are masked.

Router::from_env() reads environment variables only. A Rust application that wants the file behavior must call llmshim::env::load_all() before constructing the Router. See Models and the Router.

Proxy listener

VariableDefaultMeaning
LLMSHIM_HOSTconfig value, then 0.0.0.0Bind address
LLMSHIM_PORTconfig value, then 3000Bind port

The environment overrides [proxy]. The proxy has no built-in authentication or TLS; the bind address is not a security boundary by itself. See Deploy the proxy safely.

Retries

VariableDefaultMeaning
LLMSHIM_MAX_RETRIES3Retries after the initial provider attempt
LLMSHIM_MAX_BACKOFF_SECS60Maximum delay for one reactive retry

The retry policy is resolved when the shared client is initialized. See Errors and retries.

Proxy admission and rate limits

VariableDefaultMeaning
LLMSHIM_MAX_CONCURRENCY256In-flight upstream requests per proxy instance
LLMSHIM_QUEUE_TIMEOUT_MS5000Wait for a concurrency slot before 503
LLMSHIM_RATE_LIMIT_RPMunsetPer-provider default requests per minute
LLMSHIM_RATE_LIMIT_TPMunsetPer-provider default estimated tokens per minute
LLMSHIM_<PROVIDER>_RPMunsetProvider RPM override
LLMSHIM_<PROVIDER>_TPMunsetProvider TPM override
LLMSHIM_PENALTY_SECS5Bucket penalty after an upstream 429
LLMSHIM_REDIS_URLunsetRedis URL for optional shared coordination

<PROVIDER> is OPENAI, ANTHROPIC, GEMINI, or XAI. Per-provider values override their global dimension; an omitted dimension inherits its global value. Redis coordination requires a binary built with redis-coordination. See Scaling and rate limits.

JSONL request logging

Set LLMSHIM_LOG to append one JSON object per completed request to a file:

LLMSHIM_LOG=./llmshim.jsonl llmshim proxy

Interactive chat also accepts an explicit path, which wins over the variable:

llmshim chat --log ./chat.jsonl

Each line contains ts, model, provider, latency_ms, token counts, status, and optional error and request_id. Logging is local to the process; coordinate collection and retention in your deployment platform.