I previously configured the MiMo API, and this time I’d like to document how to use the DeepSeek API in Claude Code. In addition to basic dialogue capabilities, DeepSeek also supports web search and model name mapping, which is quite useful.
Web Search Functionality
The DeepSeek API natively supports the web search functionality within Claude Code. When using Claude Code, if the model determines that your question can only be answered through a search, it will automatically invoke the web search tool and perform the search using the DeepSeek API.
It’s important to note that calling the web search will generate additional large-model API requests (to summarize the search results), which will result in extra token costs.
Model Mapping
When using Claude Code or the Claude Desktop APP, DeepSeek will map the provided model names as follows:
| Provided Model Name | Actual Mapping |
|---|---|
Models starting with claude-opus | deepseek-v4-pro |
Models starting with claude-haiku or claude-sonnet | deepseek-v4-flash |
This means that in the developer mode of the new Claude Desktop APP, you can simply change the base_url and api_key to integrate with the DeepSeek models, without having to worry about model name restrictions.
<div align="center">
<img src="/blog/deepseek-claude-code/model-mapping.jpg" alt="Claude Code Model Mapping Illustration" width="700" />
</div>
Configuration Method
Go to the DeepSeek official website to obtain your API Key.
For Linux / Mac:
export ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic
export ANTHROPIC_AUTH_TOKEN=Your DeepSeek_API_Key
export ANTHROPIC_MODEL=deepseek-v4-pro
export ANTHROPIC_DEFAULT_SONNET_MODEL=deepseek-v4-pro
export ANTHROPIC_DEFAULT_OPUS_MODEL=deepseek-v4-pro
export ANTHROPIC_DEFAULT_HAIKU_MODEL=deepseek-v4-flash
export CLAUDE_CODE_EFFORT_LEVEL=max
export CLAUDE_CODE_SUBAGENT_MODEL=deepseek-v4-flash
For Windows (PowerShell):
$env:ANTHROPIC_BASE_URL = "https://api.deepseek.com/anthropic"
$env:ANTHROPIC_AUTH_TOKEN = "Your DeepSeek_API_Key"
$env:ANTHROPIC_MODEL = "deepseek-v4-pro"
$env:ANTHROPIC_DEFAULT_SONNET_MODEL = "deepseek-v4-pro"
$env:ANTHROPIC_DEFAULT_OPUS_MODEL = "deepseek-v4-pro"
$env:ANTHROPIC_DEFAULT_HAIKU_MODEL = "deepseek-v4-flash"
$env:CLAUDE_CODE_EFFORT_LEVEL = "max"
$env:CLAUDE_CODE_SUBAGENT_MODEL = "deepseek-v4-flash"
After setting these environment variables, run claude in your project directory.
Differences from MiMo
| Comparison Item | DeepSeek | MiMo |
|---|---|---|
| Web Search | Supported | Not supported |
| Model Mapping | Automatic mapping of model names | Use of model IDs directly |
| Pricing | Pay-per-use | Pay-per-use + Token plan |
If you need search functionality, DeepSeek is a better choice. If you’re just writing code, MiMo’s 1M context size might be more suitable.
Summary
Configuring the DeepSeek API in Claude Code is very simple, just like configuring other third-party APIs. The additional benefits include support for web search and model name mapping, which saves you some hassle. If you need to use multiple APIs, you can switch configurations for different use cases without having to uninstall and reinstall anything.