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.
Alternative authentication token. Used in contexts where
ANTHROPIC_API_KEY is not applicable.Override the Anthropic API base URL. Useful for pointing Claude Code at a proxy, staging environment, or compatible third-party endpoint.
Claude Code-specific API base URL override. Takes precedence over
ANTHROPIC_BASE_URL when set.Base URL for AWS Bedrock API access. Set this when routing Claude Code through a Bedrock endpoint.
Google Cloud project ID for Vertex AI access. Required when using Claude Code through Google Cloud’s Vertex AI platform.
Set to
1 or true to use AWS Bedrock as the API provider.Set to
1 or true to use Anthropic Foundry as the API provider.OAuth access token to use for authentication directly, bypassing the interactive login flow. Useful for automated environments.
Configuration paths
Override the directory where Claude Code stores its configuration, settings, and transcripts. Defaults to
~/.claude in your home directory.Override the path to the managed settings file. Useful in enterprise environments where the default platform path is not appropriate.
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.Set to
1 or true (or pass --bare) to run in bare mode. Bare mode skips hooks, LSP integration, plugin sync, skill directory walks, attribution, background prefetches, and all keychain/credential reads. Authentication must be provided via ANTHROPIC_API_KEY or apiKeyHelper in --settings. Useful for lightweight scripted use.Set to
1 or true to disable automatic context compaction. When set, Claude Code will not compact the conversation context even when it approaches the model’s context limit.Set to
1 or true to disable background task execution. When enabled, the run_in_background parameter is removed from Bash and PowerShell tools, and Claude cannot run shell commands as background processes.Set to
1 or true to disable extended thinking for all API calls, regardless of model support.Set to
1 or true to disable automatic memory. When disabled, Claude does not read from or write to the auto-memory directory. Set to 0 or false to explicitly enable it (useful when other conditions would disable it, such as bare mode).Auto-memory is also disabled automatically in bare mode (CLAUDE_CODE_SIMPLE) and remote mode (CLAUDE_CODE_REMOTE) unless explicitly enabled.Set to
1 or true to completely disable loading of all CLAUDE.md memory files. Claude will not read any CLAUDE.md, CLAUDE.local.md, or .claude/rules/*.md files.Set to
1 or true to suppress analytics, telemetry, and other non-essential network requests.Set to
1 or true to load CLAUDE.md files from directories added via --add-dir. By default, additional directories do not have their CLAUDE.md files loaded.Set to
1 or true to reset the working directory back to the original project root after each Bash command. Prevents one command from changing the CWD for subsequent commands.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.
Override the maximum context window size. When set, Claude Code uses this value instead of the model’s reported context limit.
Maximum number of characters captured from Bash command output. Output exceeding this limit is truncated. Useful for preventing very large command outputs from consuming context.
Override the API request timeout in milliseconds. Defaults to 300,000ms (5 minutes) for standard mode and 120,000ms (2 minutes) in remote mode.
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.Path to a file where Claude Code writes a JSONL transcript of the session. Each line is a JSON object representing a conversation event.
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.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.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 |
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 theenv field in your settings file, rather than setting them in your shell profile:
env field.