Updated 2026-07-13
Use DeepSeek in Claude Code from the Terminal
This guide is only for the Claude Code terminal workflow: install the CLI, load DeepSeek's official Anthropic-compatible environment variables, start it inside a project, and diagnose command, authentication, or model-routing problems. Claude Desktop is a separate app workflow; use the linked Desktop page for developer-mode mapping, whitelist behavior, compatibility status, and feature limits.
1. Install the Claude Code terminal CLI
Anthropic currently recommends its native installer for macOS, Linux, and WSL. The npm package remains supported and is also the installation path shown in DeepSeek's Claude Code integration page. Pick one method so an older binary does not shadow the version you expect.
After installation, confirm the command resolves and run the built-in diagnostic before adding provider settings. On native Windows, use Anthropic's PowerShell installer or WinGet and install Git for Windows if you want the Bash tool.
# macOS, Linux, or WSL — Anthropic's recommended native installer
curl -fsSL https://claude.ai/install.sh | bash
# Supported npm alternative (Node.js 18+)
npm install -g @anthropic-ai/claude-code
claude --version
claude doctorSources checked
- Anthropic Claude Code installation docs - Official native, Homebrew, WinGet, and npm installation methods.
- DeepSeek official Claude Code integration guide - DeepSeek's supported npm installation and terminal setup path.
2. Configure DeepSeek on macOS, Linux, or WSL
Set the DeepSeek Anthropic endpoint, API token, and exact model routes in the same shell where you will start Claude Code. DeepSeek's documented split uses V4 Pro for the main and Claude-style default routes, with V4 Flash reserved for Haiku-style and subagent work.
Keep the bracketed `deepseek-v4-pro[1m]` value exactly as documented. Do not substitute older compatibility aliases or invent a Claude-prefixed DeepSeek model name.
export ANTHROPIC_BASE_URL="https://api.deepseek.com/anthropic"
export ANTHROPIC_AUTH_TOKEN="sk-..."
export ANTHROPIC_MODEL="deepseek-v4-pro[1m]"
export ANTHROPIC_DEFAULT_OPUS_MODEL="deepseek-v4-pro[1m]"
export ANTHROPIC_DEFAULT_SONNET_MODEL="deepseek-v4-pro[1m]"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="deepseek-v4-flash"
export CLAUDE_CODE_SUBAGENT_MODEL="deepseek-v4-flash"
export CLAUDE_CODE_EFFORT_LEVEL="max"Sources checked
- DeepSeek official Claude Code integration guide - Primary source for the endpoint, token, model pins, subagent model, and effort level.
3. Configure DeepSeek in Windows PowerShell
PowerShell uses `$env:` assignments rather than `export`. Run these commands in the PowerShell window that will launch Claude Code. Session variables disappear when that window closes unless you persist them separately.
If the `claude` command is missing, install the native Windows build with Anthropic's PowerShell command or WinGet, then reopen the terminal before testing again.
$env:ANTHROPIC_BASE_URL="https://api.deepseek.com/anthropic"
$env:ANTHROPIC_AUTH_TOKEN="sk-..."
$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"
$env:CLAUDE_CODE_SUBAGENT_MODEL="deepseek-v4-flash"
$env:CLAUDE_CODE_EFFORT_LEVEL="max"4. Persist the terminal configuration safely
Shell exports only affect the current process and its children. For repeated use, add the non-secret routing values to your shell profile or store the environment block in `~/.claude/settings.json`. Keep the API token in a secret manager or protected environment file rather than committing it to a repository.
The settings file shown below applies to the Claude Code CLI as well as other Claude Code surfaces that read the same configuration. The purpose here is terminal persistence, not Desktop model mapping.
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.deepseek.com/anthropic",
"ANTHROPIC_AUTH_TOKEN": "sk-...",
"ANTHROPIC_MODEL": "deepseek-v4-pro[1m]",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "deepseek-v4-pro[1m]",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "deepseek-v4-pro[1m]",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "deepseek-v4-flash",
"CLAUDE_CODE_SUBAGENT_MODEL": "deepseek-v4-flash",
"CLAUDE_CODE_EFFORT_LEVEL": "max"
}
}5. Start Claude Code inside a project and verify routing
Change into the repository you want Claude Code to inspect, then launch `claude`. The CLI inherits the environment variables from that shell. Run `claude doctor` when the command starts but tools, shell access, or updates behave unexpectedly.
A successful prompt is not enough to prove the intended model handled it. Check DeepSeek's provider-side usage or request logs for the model ID. The documented configuration deliberately routes the main session and repeated subagent work differently, so Pro and Flash activity can both be correct.
cd /path/to/my-project
claude
# In a second terminal when diagnostics are needed
claude doctorSources checked
- DeepSeek official Claude Code integration guide - Documents launching `claude` inside the target project after configuration.
6. Troubleshoot installation, authentication, and model routing
`claude: command not found`: reopen the shell and confirm the native binary directory is on PATH. If more than one installation exists, keep one current installation so an older npm or Homebrew binary does not win PATH resolution.
Authentication errors: print the environment in the same shell that launches Claude Code, confirm the DeepSeek key is active, and test the Anthropic-compatible endpoint independently before changing CLI settings.
Unexpected Flash usage: confirm every Pro value includes the exact documented model string and remember that `CLAUDE_CODE_SUBAGENT_MODEL` intentionally uses Flash. Do not diagnose routing from the terminal label alone.
Missing native binary after npm install: reinstall without flags that omit optional dependencies. Anthropic's npm package delivers a platform-specific native binary through optional dependencies.
which -a claude
npm -g ls @anthropic-ai/claude-code 2>/dev/null
claude --version
claude doctorSources checked
- Anthropic Claude Code installation troubleshooting - Official PATH, conflicting-installation, permission, WSL, and npm optional-dependency checks.
7. Use the Desktop page for Desktop-only questions
Claude Desktop developer mode is a separate app surface. Model alias mapping, whitelist changes, Local mode, GUI behavior, and unsupported Desktop features do not belong in this terminal setup guide.
Open the linked Claude Desktop page when the installed app rejects a model name, when a Desktop UI label disagrees with provider logs, or when you need the current compatibility and limitation matrix. The two pages link to each other so each can answer one task without duplicating the other.
FAQ
Should I use the native installer or npm?
Anthropic recommends the native installer, while npm remains supported and is still shown in DeepSeek's integration guide. Use one method and remove conflicting older installations if PATH resolves the wrong binary.
Do I need an Anthropic API key for this route?
No. The documented DeepSeek route uses `ANTHROPIC_BASE_URL` with your DeepSeek API key in `ANTHROPIC_AUTH_TOKEN`. If Claude Code opens an unrelated login flow, first confirm those variables are loaded in the shell that launched it.
Why do I see both Pro and Flash usage?
That can be correct. DeepSeek's official recipe assigns Pro to the main and default routes and Flash to Haiku-style and subagent work. Verify the request role and provider-side model ID before treating Flash activity as an error.
Where should I store the environment variables?
Use the current shell for a quick test. For repeated use, keep non-secret routing values in your shell profile or `~/.claude/settings.json`, and protect the API token with an appropriate secret or environment-management mechanism.
Why is the `claude` command not found after installation?
Reopen the shell, check PATH, and run `which -a claude` on macOS or Linux. Multiple native, npm, or Homebrew installations can also cause the wrong binary to resolve.
Where are Claude Desktop mapping and compatibility issues covered?
Use `/claude-code`. That page owns Desktop developer mode, model mapping, whitelist behavior, provider-side verification, and feature limitations; this guide stays focused on the terminal CLI.
For the Claude Code terminal, keep the workflow narrow: install one current CLI, load DeepSeek's documented environment variables, launch it inside the target repository, run diagnostics when needed, and verify model routing from the provider side. For the separate Claude Desktop app, continue to the model-mapping and compatibility page.
Related model comparisons
Continue from this guide into structured DeepSeek-first comparison pages with model tables, routing advice, and pricing context.