Skip to content

LLM Configuration ​

Settings for controlling how LambChat interacts with language models.

Model Provider Keys ​

These are consumed by the underlying LLM SDK libraries directly (not by the Settings class):

VariableDescription
LLM_API_KEYDefault LLM API key (consumed by LiteLLM)
LLM_API_BASEDefault LLM API base URL (consumed by LiteLLM)
LLM_MODELDefault LLM model name, e.g. anthropic/claude-sonnet-4-6
ANTHROPIC_API_KEYAnthropic API key (consumed by langchain-anthropic)
ANTHROPIC_BASE_URLAnthropic-compatible API base URL

TIP

LambChat supports multi-model management through the UI. The env vars above set the default provider. Users can add additional providers and models at runtime through the settings panel.

Retry & Cache Settings ​

VariableDefaultDescription
DEFAULT_MODEL_ID(empty)Admin model configuration ID used as the default for new sessions and background jobs. Empty = first enabled model.
LLM_MAX_RETRIES3Retries after the initial call for timeout, network, rate-limit, and 5xx failures. 3 means up to 4 attempts.
LLM_RETRY_DELAY1.0Initial retry delay in seconds (exponential backoff).
LLM_REQUEST_TIMEOUT0Total seconds allowed for a complete non-streaming response. 0 or a negative value disables LambChat's non-streaming total timeout, so non-streaming waits indefinitely by default.
LLM_FIRST_EVENT_TIMEOUT30Seconds allowed for the first provider event of a streaming response. 0 or a negative value disables this deadline. After the first event, LambChat applies no total duration limit or chunk idle timeout.
LLM_MODEL_CACHE_SIZE50Model instance cache size. Prevents memory leaks from repeated instantiation.
LLM_REQUEST_HEADERS(empty)JSON object of request headers merged over the built-in anti-ban defaults (Claude Code style User-Agent/x-app for Anthropic protocol, opencode style User-Agent for OpenAI-compatible). Example: {"User-Agent": "my-agent/1.0"}. Per-model header overrides take precedence; Google protocol is not supported.
LLM_MAX_INPUT_TOKENS(none)Optional: context window size for DeepAgent auto-summarization.
LLM_TEMPERATURE(none)Optional: default temperature for LLM calls.
LLM_MAX_TOKENS(none)Optional: max output tokens for LLM calls.

DeepAgent Context Settings ​

VariableDefaultDescription
DEEPAGENT_DEFAULT_MAX_INPUT_TOKENS64000Default max input tokens for DeepAgent.

Example ​

bash
# .env
LLM_API_KEY=sk-your-api-key
LLM_API_BASE=https://api.openai.com/v1
LLM_MODEL=gpt-4o
LLM_MAX_RETRIES=3
LLM_RETRY_DELAY=1.0
LLM_REQUEST_TIMEOUT=0
LLM_FIRST_EVENT_TIMEOUT=30
LLM_MODEL_CACHE_SIZE=50