Reference
Environment variables
Configure provider credentials, transport overrides, browser launching, and local runtime endpoints.
View as textOn this page
Set variables in the process that starts the agent. A change in another terminal does not update a running process. Prefer account management for credentials and models.json for new model connections.
Never put tokens in prompts, issue reports, example JSON, or commands saved in shell history. Endpoint overrides can send credentials and conversation data to another server; use only endpoints you operate or trust.
Credential inputs
| Variable | Purpose |
|---|---|
CODEX_ACCESS_TOKEN | External OpenAI coding bearer token; does not supply a refresh token |
CODEX_ACCOUNT_ID | Explicit account identity accompanying that token |
CODEX_ID_TOKEN | Alternative identity information used to derive account identity |
CODEX_AUTH_JSON | Serialized external OpenAI authentication record; prefer importing an existing valid login rather than manufacturing OAuth fields |
CODEX_HOME | Directory containing auth.json; default ~/.codex |
OPENAI_OAUTH_CLIENT_ID | Override the OAuth application client ID; normally leave unset and use the shipped application |
GROK_AUTH_JSON | External Grok OAuth record; when valid, preferred over GROK_ACCESS_TOKEN for the environment source |
GROK_ACCESS_TOKEN | External Grok bearer token without a refresh grant |
XAI_OAUTH_CLIENT_ID | Override xAI OAuth application client ID; normally leave unset |
OPENROUTER_API_KEY | External API-billed OpenRouter credential |
GOOGLE_API_KEY | External Gemini API credential; preferred over GEMINI_API_KEY |
GEMINI_API_KEY | Alternative external Gemini API credential |
MODEL_API_KEY | Secret named by the shipped direct Meta model connection |
OPENAI_API_KEY | Direct auxiliary OpenAI authentication such as dictation; exporting this alone is not the coding-account selector |
Enabled managed credentials can take precedence over environment sources. OpenAI combines eligible managed and external accounts and suppresses duplicate account identities; this is not a simple last-variable-wins rule. See provider authentication and billing.
Direct-provider transport overrides
These variables change existing provider clients, not the model catalog. Nonempty string overrides are accepted as supplied. Integer timeout strings must parse completely; invalid or empty values fall back to the client's default. Use positive timeouts rather than relying on transport-specific behavior of zero or negative values. The default is 600 seconds for the clients below.
| Variable | Default / interpretation |
|---|---|
OPENROUTER_BASE_URL | https://openrouter.ai/api/v1 |
OPENROUTER_MODEL_MAP | Empty; comma-separated exact source=target mappings |
OPENROUTER_DEFAULT_MODEL | openai/gpt-5.1; fallback when the request has no usable OpenRouter slug |
OPENROUTER_TIMEOUT_SECONDS | 600; provider request timeout |
OPENROUTER_HTTP_REFERER | Absent; optional HTTP-Referer attribution header |
OPENROUTER_APP_TITLE | Absent; optional X-Title attribution header |
XAI_GROK_BASE_URL | Native xAI API base; leave unset for normal direct access |
XAI_GROK_MODEL_MAP | Empty; comma-separated exact source=target mappings |
XAI_GROK_DEFAULT_MODEL | grok-4.6 |
XAI_GROK_TIMEOUT_SECONDS | 600; provider request timeout |
XAI_GROK_CLIENT_VERSION | Shipped client identity; override only for a known compatibility requirement |
GEMINI_BASE_URL | Direct Gemini API endpoint; distinct from subscription Code Assist |
GEMINI_CODE_ASSIST_BASE_URL | https://cloudcode-pa.googleapis.com/v1internal |
GEMINI_DEFAULT_MODEL | gemini-3.7-flash |
GEMINI_TIMEOUT_SECONDS | 600; provider request timeout |
Model-map entries trim whitespace around both sides and ignore malformed or empty entries. Duplicate source keys retain the final entry. For example, source-a=target-a,source-b=target-b describes two exact replacements, not wildcard rules. Do not use mapping to claim a model has another model's capabilities or context limit.
Organization-gateway xAI routing deliberately preserves advertised model names, uses the gateway's native endpoint and disables redirects. Direct xAI environment overrides do not redirect that authenticated gateway route.
OPENROUTER_TIMEOUT_SECONDS=900 agent-cli --provider openrouterUse /session-info and a small request to verify the intended provider. Increasing a timeout does not resolve an invalid key, unknown model, incompatible endpoint or exhausted account quota. Remove the override to return to the shipped transport default.
Local helpers and browser selection
| Variable | Behavior |
|---|---|
CLAUDE_CODE_EXECUTABLE | Select the Claude Code executable for authentication/runtime discovery; use a trusted installed program |
HASKELL_AGENT_APPLE_SESSION_TITLE | Select the on-device title helper; normal discovery uses PATH or a supported local build |
BROWSER | Single executable name or path, launched with the authorization URL as one argument; not a shell command with flags |
XAI_STT_LANGUAGE | Dictation language; defaults to English, for example pt for Portuguese |
Without BROWSER, browser launching tries open and then xdg-open. If you supply a browser executable and it cannot launch, correct or unset the variable; an arbitrary command string will not be interpreted by a shell. Remote/headless sessions still need a way to complete the provider's browser authorization.
Local runtime paths
These are advanced local-process coordination controls. Use the same values in processes that must observe or contact one another. Do not point them at a shared, untrusted directory; these endpoints are not a network deployment API.
| Variable | Default / purpose |
|---|---|
HASKELL_AGENT_OBSERVATION_DIRECTORY | ~/.haskell-agent/observation; session observation socket directory |
HASKELL_AGENT_INBOX_DIRECTORY | ~/.haskell-agent/inbox; session inbox socket directory |
HASKELL_AGENT_EXECUTABLE | Override the agent executable used for managed external process launches |
Leave directory overrides unset instead of supplying an empty value. Observation and inbox services are ancillary; failing to create their endpoint can leave execution running without that coordination facility. Check the chosen directory and its permissions rather than repeatedly starting duplicate agents.
MCP entry environment is separate
MCP_ACCESS_TOKEN and MCP_OAUTH_TOKEN_FILE are read from a server entry's env map. They are not interchangeable with a provider API key. Use the MCP authentication reference for managed OAuth and legacy token-file behavior.