11 KiB
Documentation Index
Fetch the complete documentation index at: https://vineetagarwal-code-claude-code.mintlify.app/llms.txt Use this file to discover all available pages before exploring further.
Environment variables
Environment variables that Claude Code reads to configure authentication, API access, behavior, and runtime options.
Claude Code reads environment variables at startup. These variables let you configure authentication, point to custom API endpoints, tune runtime behavior, and control which features are active — without modifying settings files.
Authentication
API key for authenticating directly with the Anthropic API. When set, Claude Code uses this key instead of (or in addition to) OAuth credentials. Takes priority over OAuth when present in most contexts.export ANTHROPIC_API_KEY="sk-ant-..."
export ANTHROPIC_BASE_URL="https://my-proxy.example.com"
Configuration paths
Override the directory where Claude Code stores its configuration, settings, and transcripts. Defaults to `~/.claude` in your home directory.export CLAUDE_CONFIG_DIR="/opt/claude-config"
Model selection
Default model to use. Overridden by the `model` setting in settings files and by explicit `--model` flags. Model to use for sub-agent tasks spawned by the main agent. When not set, sub-agents use the same model as the main session. Model to use when running in auto mode. Defaults to the main session model when not specified.Behavior toggles
Set to `1` or `true` to enable remote/container mode. In this mode, Claude Code adjusts its behavior for non-interactive environments — extended API timeouts (120s vs. 300s), suppressed interactive prompts, and adapted output formatting.export CLAUDE_CODE_REMOTE=1
export DISABLE_AUTO_COMPACT=1
Auto-memory is also disabled automatically in bare mode (CLAUDE_CODE_SIMPLE) and remote mode (CLAUDE_CODE_REMOTE) unless explicitly enabled.
Resource limits
Override the maximum number of output tokens per API response. When not set, Claude Code uses the model's default maximum. Useful for controlling costs in automated workflows.export CLAUDE_CODE_MAX_OUTPUT_TOKENS=4096
export BASH_MAX_OUTPUT_LENGTH=50000
export API_TIMEOUT_MS=60000
Telemetry and observability
Set to `1` or `true` to enable OpenTelemetry export of traces, metrics, and logs. Requires additional OTEL configuration (endpoint, headers, etc.) to be set via standard OpenTelemetry environment variables.export CLAUDE_CODE_ENABLE_TELEMETRY=1
export OTEL_EXPORTER_OTLP_ENDPOINT="https://otel.example.com"
export CLAUDE_CODE_JSONL_TRANSCRIPT="/tmp/session.jsonl"
Node.js runtime
Standard Node.js options passed to the runtime. Claude Code reads this to detect flags like `--max-old-space-size` and adjusts its behavior accordingly. Claude Code itself sets this internally to configure heap size for large sessions.export NODE_OPTIONS="--max-old-space-size=4096"
Host platform override
Override the reported host platform for analytics. Accepts `"win32"`, `"darwin"`, or `"linux"`. Useful when Claude Code runs in a container (where `process.platform` reports the container OS) but the actual host platform differs.export CLAUDE_CODE_HOST_PLATFORM=darwin
Cloud provider region overrides
Claude Code supports per-model Vertex AI region overrides. Set the corresponding environment variable to route a specific model to a different region.
| Model prefix | Environment variable |
|---|---|
claude-haiku-4-5 |
VERTEX_REGION_CLAUDE_HAIKU_4_5 |
claude-3-5-haiku |
VERTEX_REGION_CLAUDE_3_5_HAIKU |
claude-3-5-sonnet |
VERTEX_REGION_CLAUDE_3_5_SONNET |
claude-3-7-sonnet |
VERTEX_REGION_CLAUDE_3_7_SONNET |
claude-opus-4-1 |
VERTEX_REGION_CLAUDE_4_1_OPUS |
claude-opus-4 |
VERTEX_REGION_CLAUDE_4_0_OPUS |
claude-sonnet-4-6 |
VERTEX_REGION_CLAUDE_4_6_SONNET |
claude-sonnet-4-5 |
VERTEX_REGION_CLAUDE_4_5_SONNET |
claude-sonnet-4 |
VERTEX_REGION_CLAUDE_4_0_SONNET |
# Route Opus 4 to a specific Vertex region
export VERTEX_REGION_CLAUDE_4_0_OPUS="us-central1"
The default Vertex region is controlled by CLOUD_ML_REGION (defaults to us-east5).
AWS credentials
For Bedrock access, Claude Code respects standard AWS credential environment variables:
AWS region for Bedrock API calls. Falls back to `AWS_DEFAULT_REGION`, then defaults to `us-east-1`. Fallback AWS region when `AWS_REGION` is not set.Setting environment variables for all sessions
You can set environment variables that apply to every Claude Code session using the env field in your settings file, rather than setting them in your shell profile:
{
"env": {
"DISABLE_AUTO_COMPACT": "1",
"BASH_MAX_OUTPUT_LENGTH": "30000"
}
}
See Settings for documentation on the env field.
Built with Mintlify.