Updated 2026-10-11
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 22+)
npm install -g @anthropic-ai/claude-code
claude --version
claude doctorSources
- Anthropic Claude Code installation docs - Official installation methods; npm requires Node.js 22 or later.
- DeepSeek official Claude Code integration guide - DeepSeek's supported npm installation and terminal setup path.
2. Configure DeepSeek on macOS, Linux, or WSL
Set these variables in the shell that launches Claude Code. The current official recipe uses deepseek-flash[1m] for the main, Opus, and Sonnet slots, and deepseek-flash for Haiku and subagents.
Keep the documented [1m] suffix on the main, Opus, and Sonnet values. The default recipe uses Flash; selecting Pro for harder tasks is a separate routing choice.
export ANTHROPIC_BASE_URL="https://api.deepseek.com/anthropic"
export ANTHROPIC_AUTH_TOKEN="sk-..."
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"Sources
- 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-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"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-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"
}
}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.
Verify the actual model in provider usage records. The current default recipe uses Flash across main and subagent roles; Pro usage should follow an explicit configuration choice.
cd /path/to/my-project
claude
# In a second terminal when diagnostics are needed
claude doctorSources
- 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: confirm the variable names and endpoint in the launching shell without printing the token. Check key validity and provider-side errors before changing model settings.
Unexpected model usage: the current official recipe defaults to Flash. Check all main/default/subagent settings and provider-side model records if you intended to use Pro.
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
- 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 Flash usage?
That is expected with the current official recipe: it uses Flash for main and subagent work. If you select Pro separately, verify that route in provider usage records.
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.