Last reviewed: November 18, 2026.
You can use DeepSeek with Claude Code by connecting the CLI to https://api.deepseek.com/anthropic and supplying a DeepSeek API key. Claude Code remains the coding agent on your computer, while DeepSeek handles the model requests. DeepSeek publishes this configuration in its Claude Code integration guide.
There is a support boundary: Anthropic does not support routing Claude Code to non-Claude models. Treat this as a DeepSeek-documented compatibility setup whose behavior can change with client and API updates.

The walkthrough below starts with a temporary terminal setup, checks the active connection, and runs a small file task. After that, you can decide whether to save the configuration for regular use.
What you need before connecting DeepSeek
- A working Claude Code installation, or permission to install it on your computer.
- A DeepSeek API key from the DeepSeek Platform and an account with available API balance.
- An empty test folder outside your existing projects, so the first task has a clear, limited scope.
This guide covers the local Claude Code CLI connected directly to DeepSeek’s hosted API. It does not require downloading model weights or operating a GPU server. Model requests use DeepSeek’s API billing.
If you already use another provider, check your existing configuration first. A saved env entry can override a shell variable, as explained in Claude Code’s settings reference. The temporary shell below preserves your original shell environment, but still loads applicable Claude Code settings and organization policies.
Install or check Claude Code
For a new installation, use the native installer recommended in Anthropic’s setup documentation. Choose the command for your terminal.
macOS, Linux, or WSL:
curl -fsSL https://claude.ai/install.sh | bash
Native Windows PowerShell:
irm https://claude.ai/install.ps1 | iex
Open a new terminal after installation, then check that the executable is available:
claude --version
A working installation prints a version number. If the command is missing, follow the PATH troubleshooting in the official setup guide before configuring an API provider.

The native route does not require a separate Node.js installation. If you choose npm instead, the current Claude Code requirements specify Node.js 22 or later. On native Windows, Git for Windows is recommended for Bash-based tooling; Claude Code can use PowerShell when Git is absent.
Connect DeepSeek in a temporary terminal session
Open a terminal in your empty test folder and follow one operating-system branch below. The model and context values follow DeepSeek’s current integration guide. The hidden key prompts keep the credential out of the commands you paste into shell history.

Use your own DeepSeek API key when prompted. Enter the key as prompt input, rather than replacing a placeholder inside an exported command. The running process still receives the key as an environment-variable string, so avoid printing its environment or sharing diagnostic dumps containing secrets.
macOS, Linux, and WSL
Start a child Bash shell. This also makes the following input syntax consistent when your usual macOS shell is Zsh:
bash --noprofile --norc
Run this key prompt by itself, paste your key when it asks, and press Enter. Your input is hidden:
read -r -s -p "DeepSeek API key: " ANTHROPIC_AUTH_TOKEN; printf '\n'
Once the shell prompt returns, paste the configuration and launch command:
export ANTHROPIC_AUTH_TOKEN
export ANTHROPIC_BASE_URL='https://api.deepseek.com/anthropic'
export ANTHROPIC_MODEL='deepseek-flash[1m]'
export ANTHROPIC_DEFAULT_OPUS_MODEL='deepseek-flash[1m]'
export ANTHROPIC_DEFAULT_SONNET_MODEL='deepseek-flash[1m]'
export ANTHROPIC_DEFAULT_HAIKU_MODEL='deepseek-flash'
export CLAUDE_CODE_SUBAGENT_MODEL='deepseek-flash'
export CLAUDE_CODE_EFFORT_LEVEL='max'
export CLAUDE_CODE_AUTO_COMPACT_WINDOW='786432'
claude --model 'deepseek-flash[1m]'
Windows PowerShell
Start a child Windows PowerShell session from your test folder:
powershell.exe -NoProfile
Run the following prompt by itself, enter your key, and press Enter. PowerShell’s Read-Host -AsSecureString masks the input:
$deepseekKey = Read-Host "DeepSeek API key" -AsSecureString
Then convert the value for the CLI, set the provider configuration, and launch:
$env:ANTHROPIC_AUTH_TOKEN = [System.Net.NetworkCredential]::new("", $deepseekKey).Password
$deepseekKey.Dispose()
Remove-Variable deepseekKey
$env:ANTHROPIC_BASE_URL = "https://api.deepseek.com/anthropic"
$env:ANTHROPIC_MODEL = "deepseek-flash[1m]"
$env:ANTHROPIC_DEFAULT_OPUS_MODEL = "deepseek-flash[1m]"
$env:ANTHROPIC_DEFAULT_SONNET_MODEL = "deepseek-flash[1m]"
$env:ANTHROPIC_DEFAULT_HAIKU_MODEL = "deepseek-flash"
$env:CLAUDE_CODE_SUBAGENT_MODEL = "deepseek-flash"
$env:CLAUDE_CODE_EFFORT_LEVEL = "max"
$env:CLAUDE_CODE_AUTO_COMPACT_WINDOW = "786432"
claude --model "deepseek-flash[1m]"
These assignments use PowerShell’s process environment. They do not write permanent Windows User or Machine variables.
Verify that Claude Code is using the intended backend
Before sending a coding prompt, run this command inside Claude Code:
/status
The gateway connection guide documents the base URL and credential-source information shown here. Check these items:
- Destination: the Anthropic base URL should be
https://api.deepseek.com/anthropic. - Credential source: the active authentication should correspond to the DeepSeek token you supplied.
- Model: check the configured DeepSeek model, accounting for the model-label behavior explained below.
- Loaded settings: if something differs, inspect the listed setting sources and their relevant entries.
If the destination or credentials are wrong, stop before sending project content. A value printed by your shell only proves what that shell contains; it does not prove that Claude Code used it after loading configuration files.

Next, send this small test task:
Create a file named smoke-test.txt containing exactly:
deepseek-connection-ok
Then read the file back and report its contents.
Do not install packages, contact other services, or modify any other file.
Review any tool-permission prompts. Confirm that the file was actually created in the test folder and contains the expected line. A successful answer without the file would verify less than a completed file operation.
Check DeepSeek’s account usage or billing records as additional evidence after the request. If other applications share the account, an aggregate usage change alone cannot identify which process generated it. Use the configuration check, completed task, and provider records together.
Asking the assistant to identify its own model is not a reliable routing test. Similarly, a separate successful API request would validate that request’s key and endpoint, but would not establish what your Claude Code process used.
Understand the model names, context, and effort settings
The current DeepSeek model reference lists deepseek-flash and deepseek-v4-pro. Start with the Flash configuration above to establish a working connection, then evaluate another model on a representative task if needed.
| Setting group | Purpose in this setup |
|---|---|
ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN | Select the destination and supply its bearer credential. |
ANTHROPIC_MODEL and ANTHROPIC_DEFAULT_*_MODEL | Choose the main model and what the built-in model aliases select. |
CLAUDE_CODE_SUBAGENT_MODEL | Set the default model for subagent work. |
CLAUDE_CODE_EFFORT_LEVEL | Set the requested reasoning effort. |
CLAUDE_CODE_AUTO_COMPACT_WINDOW | Control the conversation size at which automatic compaction occurs. |
See Claude Code’s environment-variable reference for those client controls. The [1m] suffix tells Claude Code to use a one-million-token context window; it does not grant one million output tokens. The compaction value 786432 is a conversation-management setting, not a spending cap. See model and context configuration.
The example pins the local Opus and Sonnet aliases to Flash. Consequently, an “Opus” option can refer to the model assigned to that slot. Separately, DeepSeek’s server-side compatibility mapping maps received claude-opus* names to Pro and other unsupported claude* names to Flash. Explicit DeepSeek IDs make your intent easier to inspect.
To try Pro for the main session, leave the DeepSeek endpoint and credential active, exit Claude Code, and launch:
claude --model "deepseek-v4-pro[1m]"
This launch flag changes the main model; the separate default subagent setting above remains Flash. Flash currently supports vision, while Pro does not, according to the model reference. Include the actual input types your project needs when evaluating the choice.
Use --model for a launch-specific choice, as documented in the CLI reference. Current /model selections can save a default for future sessions; the picker also offers a session-only selection. A model switch is therefore worth checking before assuming your next launch will use the old default.
The supplied max effort matches DeepSeek’s guide. DeepSeek documents low, high, and max effort levels in its thinking-mode reference. Evaluate effort using task completion, elapsed time, and token usage; a larger setting is not a substitute for checking the resulting code.
Save a reusable configuration without committing the key
After the temporary setup works, choose where the non-secret configuration should live. Claude Code documents these settings scopes:
| Location | Scope |
|---|---|
~/.claude/settings.json | Your projects on this computer. On Windows, the corresponding path is %USERPROFILE%\.claude\settings.json. |
.claude/settings.local.json | Your configuration for one project. |
.claude/settings.json | Shared project configuration that may be committed to version control. |
Back up an existing file, then merge the entries below into its env object. Preserve unrelated settings. Keep the API key in your credential-injection workflow, such as the interactive prompt above or your organization’s secret tooling.
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.deepseek.com/anthropic",
"ANTHROPIC_MODEL": "deepseek-flash[1m]",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "deepseek-flash[1m]",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "deepseek-flash[1m]",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "deepseek-flash",
"CLAUDE_CODE_SUBAGENT_MODEL": "deepseek-flash",
"CLAUDE_CODE_EFFORT_LEVEL": "max",
"CLAUDE_CODE_AUTO_COMPACT_WINDOW": "786432"
}
}
This file deliberately contains no credential. Supply the token before launching each new process. If you manually create .claude/settings.local.json, add it to .gitignore; do not assume the file was excluded automatically.
Restart Claude Code and repeat the destination check after changing configuration. A reusable setup is easier to maintain when one location owns the provider settings, instead of conflicting values spread across shell profiles and several JSON files.
Know which features depend on API compatibility
A working text response establishes basic connectivity. Before using the setup for substantial work, also test file operations, tool results, your usual input types, and any integrations you rely on.
| Capability or field | What the current documentation says |
|---|---|
| Client tool calls and streaming | Supported by DeepSeek’s Anthropic-compatible API. |
| Thinking controls | adaptive is treated as enabled; budget_tokens is ignored. |
| Anthropic cache-control fields | Ignored by this compatibility interface. |
API-level mcp_servers | Ignored; this is distinct from tools connected to the Claude Code client. |
max_tokens | Some Claude Code main-agent requests can receive a higher effective limit through compatibility handling. |
These limits come from DeepSeek’s compatibility reference. Do not use the ignored fields as operational controls, or treat max_tokens as a guaranteed hard budget in every Claude Code request.

Claude Code has its own MCP connections, which expose tools to the client. The ignored API field does not establish that every MCP integration fails. Test the specific connection and its tool-call round trip before depending on it.
Cloud and remote features have separate requirements. In particular, Claude Code disables Remote Control when its base URL points to a non-Anthropic host; see the environment-variable documentation. A successful CLI setup should not be treated as a feature guarantee for every Claude interface.
How billing and code handling change
DeepSeek bills requests sent to its endpoint against your DeepSeek API balance. A Claude subscription does not fund those requests. Check the current DeepSeek pricing rather than applying Claude’s token prices to this route.

At the review date, model-triggered server-side web search and fetch have no separate tool-call fee, while the associated model-token usage remains billable. Standalone Search and Fetch API calls follow separate pricing. DeepSeek’s pricing page explains that distinction.
For a useful cost comparison, run a small representative task and record whether it produced an acceptable change, how much revision it needed, and the resulting API usage. A low per-token price does not by itself tell you the cost of finishing a task.
The hosted inference route sends model-request content, including selected project context, to DeepSeek. Keep the initial test free of confidential code and check your organization’s rules before using company repositories. Client background traffic and connected tools can still contact other services; the gateway connection documentation describes traffic outside the configured model endpoint.
Changing a base URL does not create a local model deployment. It also does not configure the separate accounts, network connections, or permissions of tools you attach to the coding agent.
Troubleshoot DeepSeek with Claude Code
Diagnose the layer that failed before changing several settings at once. A missing executable, a rejected credential, and an unsupported request field require different fixes.
| Symptom | What to check first |
|---|---|
claude is not found | Open a new terminal and verify the installation directory is on PATH. |
| The old provider or a login flow still appears | Inspect /status, saved env entries, credential helpers, and cloud-provider selection variables. |
| HTTP 401 | Check the DeepSeek key and the actual destination; look for an old token in loaded settings. |
| HTTP 402 | Check the DeepSeek API balance. |
| HTTP 400 or 422 | Check the error details, model ID, endpoint format, and unsupported fields. |
| HTTP 429 | Reduce concurrent sessions or subagent activity and consult DeepSeek’s current limits. |
| HTTP 500 or 503 | Wait before retrying and check the provider’s service status. |
| The CLI works, but VS Code does not | Check which environment and settings the extension process loaded. |
The HTTP meanings are documented in DeepSeek’s error reference. For load-related failures, use the current rate-limit reference; adding account balance addresses a different problem from reducing request pressure.

Resolve conflicting credentials or provider settings
Claude Code’s authentication precedence puts selected cloud-provider routes before the normal token/key chain. Check CLAUDE_CODE_USE_BEDROCK, CLAUDE_CODE_USE_VERTEX, and CLAUDE_CODE_USE_FOUNDRY if you previously used those services. Within the normal chain, ANTHROPIC_AUTH_TOKEN precedes ANTHROPIC_API_KEY.
Correct the specific conflicting values you own, keeping a record of their previous values. Managed settings may deliberately restrict providers; ask the administrator for the approved configuration when that applies. Deleting the entire .claude directory is an unnecessarily broad response to a single routing problem.
If an update breaks a previously working setup
Record the Claude Code version, model ID, endpoint, and exact error message. Reproduce the issue with the small test folder, then compare the request problem with DeepSeek’s compatibility documentation. Remove keys and private project content from any support report.
Avoid assuming that a larger timeout fixes every failure. An immediate parameter rejection needs a request or compatibility correction; waiting longer does not change the rejected field.
Return to your previous Claude Code configuration
For the temporary setup, leave Claude Code with /exit, then run this at the child shell prompt:
exit
You are back in the original shell, with its earlier environment. Start a new Claude Code session there and inspect /status before resuming work.
This restores shell-scoped settings only. If you saved a model through /model, changed /config, or edited a configuration file, restore those changes separately. For persistent DeepSeek configuration, restore the specific entries from your backup and restart the affected application.
Preserve existing sign-in credentials and unrelated preferences. Confirm the intended destination and model after switching back, just as you did when switching to DeepSeek.
Frequently asked questions
Do I need Claude Pro or Max to use this route?
The model requests in this setup use DeepSeek credentials and API balance. A Claude subscription does not pay for them. Organization-managed installations can still impose separate sign-in and provider requirements.
Do I need Claude Code Router, CC Switch, or a proxy?
The direct setup above connects to DeepSeek without a separate local router. A switching tool can be useful if you manage several providers, but evaluate its credential storage and configuration behavior before adding it to the workflow.
Can I use the setup in the Claude Code VS Code extension?
The extension supports provider configuration through the documented VS Code integration settings. An already-running editor will not automatically receive variables you added to another terminal. Close the relevant editor processes, provide the configuration, and launch the editor from that environment, or use the appropriate settings and credential mechanism.
Does this change Claude Desktop or Claude web chat?
These steps configure the local CLI process. Claude Desktop uses a separate third-party inference configuration, and Claude cloud sessions do not adopt this terminal’s provider variables. Follow the documentation for the specific interface you intend to use.
Why do older guides show different DeepSeek model names?
Model defaults and aliases change. The current DeepSeek model page lists deepseek-flash and deepseek-v4-pro; use its current identifiers when adapting older examples. A historical tutorial’s model name is not evidence that the same endpoint still accepts it.
