How to Configure Environment Variables for Claude Code on Windows: Complete Guide
To configure Claude Code on Windows, set the ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN, and model-specific variables in your PowerShell session or system environment variables, then launch the tool to automatically apply the configuration.
Claude Code reads its runtime configuration from environment variables that override any values stored in settings.json. According to the deepseek-ai/awesome-deepseek-agent repository, this mechanism lets you keep sensitive credentials like your DeepSeek API key outside of source-controlled files while enabling per-session customization on Windows systems.
Essential Environment Variables for Claude Code
The docs/claude_code.md file in the repository defines eight key variables that control Claude Code behavior on Windows【/cache/repos/github.com/deepseek-ai/awesome-deepseek-agent/main/docs/claude_code.md#L77-L88】. When present, these variables take precedence over configuration file settings.
ANTHROPIC_BASE_URL– The endpoint URL for the DeepSeek Anthropic API (typicallyhttps://api.deepseek.com/anthropic)ANTHROPIC_AUTH_TOKEN– Your DeepSeek API authentication keyANTHROPIC_MODEL– The default model for general requestsANTHROPIC_DEFAULT_OPUS_MODEL– Model identifier for high-capacity "opus" requestsANTHROPIC_DEFAULT_SONNET_MODEL– Model identifier for balanced "sonnet" requestsANTHROPIC_DEFAULT_HAIKU_MODEL– Model identifier for fast "haiku" requestsCLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC– Set to1to disable telemetry trafficCLAUDE_CODE_EFFORT_LEVEL– Controls reasoning effort (e.g.,maxfor maximum capability)
Setting Variables in PowerShell
PowerShell is the recommended shell for configuring Claude Code on Windows. You can apply settings temporarily for the current session or persist them permanently.
Temporary Session Configuration
Use the $env: prefix to define variables that last only until you close the terminal window. This approach is ideal for testing different API keys or endpoints without affecting other applications.
$env:ANTHROPIC_BASE_URL="https://api.deepseek.com/anthropic"
$env:ANTHROPIC_AUTH_TOKEN="<your DeepSeek API Key>"
$env:ANTHROPIC_MODEL="deepseek-v4-pro[1m]"
$env:ANTHROPIC_DEFAULT_OPUS_MODEL="deepseek-v4-pro[1m]"
$env:ANTHROPIC_DEFAULT_SONNET_MODEL="deepseek-v4-pro[1m]"
$env:ANTHROPIC_DEFAULT_HAIKU_MODEL="deepseek-v4-flash[1m]"
$env:CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC="1"
$env:CLAUDE_CODE_EFFORT_LEVEL="max"
Persistent User Environment Variables
To maintain these settings across system restarts, use the .NET environment method to write to the User registry hive. This makes the variables available to all future PowerShell sessions and the Claude Code VS Code extension.
[Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", "https://api.deepseek.com/anthropic", "User")
[Environment]::SetEnvironmentVariable("ANTHROPIC_AUTH_TOKEN", "<your DeepSeek API Key>", "User")
[Environment]::SetEnvironmentVariable("ANTHROPIC_MODEL", "deepseek-v4-pro[1m]", "User")
[Environment]::SetEnvironmentVariable("CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC", "1", "User")
[Environment]::SetEnvironmentVariable("CLAUDE_CODE_EFFORT_LEVEL", "max", "User")
Alternatively, open System Properties → Advanced → Environment Variables and add each variable manually through the GUI.
Setting Variables in Command Prompt (CMD)
If you prefer Command Prompt, use the set command to configure the runtime environment. These settings apply only to the current CMD session and disappear when the window closes.
set ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic
set ANTHROPIC_AUTH_TOKEN=<your DeepSeek API Key>
set ANTHROPIC_MODEL=deepseek-v4-pro[1m]
set ANTHROPIC_DEFAULT_OPUS_MODEL=deepseek-v4-pro[1m]
set ANTHROPIC_DEFAULT_SONNET_MODEL=deepseek-v4-pro[1m]
set ANTHROPIC_DEFAULT_HAIKU_MODEL=deepseek-v4-flash[1m]
set CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
set CLAUDE_CODE_EFFORT_LEVEL=max
After executing these commands, launch Claude Code from the same terminal window to inherit the configuration.
Verifying Your Configuration
Once you have set the environment variables, verify that Claude Code recognizes them by checking the application startup logs or running a test query. The tool automatically detects these variables at launch and routes API requests to the DeepSeek endpoint specified in ANTHROPIC_BASE_URL. If you configured persistent variables, restart your terminal or VS Code to ensure the new environment state loads.
Summary
- Environment variables override any values in Claude Code's
settings.jsonconfiguration file. - Eight specific variables control the API endpoint, authentication, model selection, and telemetry settings.
- PowerShell syntax uses
$env:VARNAME="value"for temporary settings and[Environment]::SetEnvironmentVariable()for permanent configuration. - Command Prompt supports temporary configuration via
setcommands but requires manual system settings for persistence. - Source documentation in
docs/claude_code.mdlines 77-88 provides the authoritative variable list for Windows users.
Frequently Asked Questions
Do environment variables override the settings.json file in Claude Code?
Yes. When you configure environment variables for Claude Code on Windows, they take precedence over values stored in settings.json. This hierarchy allows you to commit non-sensitive configuration files to version control while keeping API keys and endpoint URLs in your local environment.
How do I persist environment variables across PowerShell restarts?
Use the .NET environment method. Execute [Environment]::SetEnvironmentVariable("VARIABLE_NAME", "value", "User") for each variable you need to persist. The "User" scope writes to your Windows user profile, making the variables available in all future PowerShell sessions and GUI applications like VS Code.
Can I use Command Prompt instead of PowerShell to configure Claude Code?
Yes, but only for temporary configuration. The set command in CMD applies variables to the current session only. For permanent configuration on Windows, PowerShell's [Environment]::SetEnvironmentVariable() method or the System Properties GUI is required, as CMD does not provide a native command to modify user-level environment variables.
Where is the official documentation for Claude Code Windows configuration?
The authoritative guide resides in docs/claude_code.md. The deepseek-ai/awesome-deepseek-agent repository maintains this file, which documents the specific environment variable names, their purposes, and Windows-specific syntax for both PowerShell and Command Prompt【/cache/repos/github.com/deepseek-ai/awesome-deepseek-agent/main/docs/claude_code.md】.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →