DeepSeek V4 Flash in Cursor, Claude Code & Codex: Setup Guide
DeepSeek V4 Flash in Cursor, Claude Code and Codex: the complete setup guide. Official env vars, base URLs, model-name mapping, and the reasoning_content fix.
Get Your DeepSeek API Key and Pick a Base URL
DeepSeek V4 speaks two native agent dialects. The OpenAI-compatible endpoint at https://api.deepseek.com and the Anthropic-compatible endpoint at https://api.deepseek.com/anthropic[4] both accept the same sk- API key. Create one key at platform.deepseek.com/api_keys and it works in every tool below.
- Create your key at platform.deepseek.com/api_keys. It starts with sk- and runs pay-as-you-go, so add balance before heavy use.
- Model names are case-sensitive. Use deepseek-v4-flash for fast, cheap, high-frequency work and deepseek-v4-pro for complex reasoning[5].
- The old aliases deepseek-chat and deepseek-reasoner retired on July 24, 2026[1]. Requests to them now return a hard error.
- Append [1m] to select the 1M-context variant of a model, for example deepseek-v4-pro[1m].
| Endpoint | Format | Best for |
|---|---|---|
| https://api.deepseek.com | OpenAI Chat Completions (plus Responses API since the 0731 build) | Cursor, Codex, Cline, Continue, OpenCode |
| https://api.deepseek.com/anthropic | Anthropic Messages (/v1/messages) | Claude Code, Claude Desktop, Copilot CLI |
One key, two endpoints. The Anthropic endpoint is currently the only official path that reaches the deepseek-v4-pro tier through Claude Code; the OpenAI endpoint powers Cursor and Codex.
curl https://api.deepseek.com/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DEEPSEEK_API_KEY}" \
-d '{
"model": "deepseek-v4-flash",
"messages": [
{"role": "user", "content": "Hello!"}
],
"stream": false
}'Add DeepSeek V4 Flash in Cursor (Settings → Models)
Adding DeepSeek V4 Flash in Cursor takes about two minutes. DeepSeek ships no dedicated Cursor integration page[6], so this is the community-verified path: Settings to Models to Add Model.
Once Verify passes, select the new model in the Chat dropdown before opening a thread. Pro and Flash can coexist as two entries sharing the same key and base URL.
Cursor enforces its own per-plan context ceiling, so in practice you hit Cursor's limit before DeepSeek's 1M-token window.
- Open Settings (Cmd+, on macOS or Ctrl+, on Windows) and go to Models.
- Toggle Override OpenAI Base URL and enter https://api.deepseek.com. Do not append /v1.
- Paste your DeepSeek API key into the OpenAI API Key field. Cursor stores it locally and forwards it as a Bearer token.
- In Model Names, click + Add model and type the exact name: deepseek-v4-flash or deepseek-v4-pro. There is no deepseek-v4 alias.
- Click Verify to test the connection.
| Verify result | Meaning | Fix |
|---|---|---|
| Green check | Connection OK | Pick the model in the Chat dropdown and start a thread |
| 404 | Wrong base URL | Remove the /v1 suffix — the base URL is https://api.deepseek.com |
| 401 | Authentication fails | Recreate the API key at platform.deepseek.com/api_keys |
| model-not-found | Wrong model name | Use deepseek-v4-flash or deepseek-v4-pro exactly |
Custom models only route Chat and the Composer agent. Tab autocomplete still runs on Cursor's own models, and Background Agents did not support custom DeepSeek models as of May 2026.
Connect Claude Code with the Official Environment Variables
DeepSeek's official Claude Code integration is the most authoritative of the three[3]. Point Claude Code at the Anthropic endpoint, set the eight environment variables, and Claude Code routes to DeepSeek. Install first with npm install -g @anthropic-ai/claude-code (Node.js 18+ required; Windows also needs Git for Windows).
The official config gives heavy reasoning to Pro and cheap high-frequency work to Flash. Flash carries the Haiku tier and sub-agents; Pro carries the main task. The [1m] suffix selects the 1M-context variant. On Windows, write each export with the $env: form. Verify the install with claude --version.
Web Search works natively: Claude Code calls DeepSeek's Web Search tool when the model decides it is needed, and summarizing the results adds token cost. The awesome-deepseek-agent repo adds one more variable, CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1[8], and writes the Haiku tier as deepseek-v4-flash[1m].
- Community reports put Claude Code on DeepSeek at roughly $7/month instead of $200/month using just two environment variables (MG-Cafe, live-tested, not official numbers).
- The same mapping lets Claude Desktop connect: enable developer mode, change the base URL and API key, and the claude-* names bypass the app's model-name restrictions.
The Anthropic endpoint ignores image and document content blocks, cache_control, MCP tool-use blocks, anthropic-beta and anthropic-version headers, and top_k. Do not migrate multimodal or MCP-dependent workflows as-is.
npm install -g @anthropic-ai/claude-code
export ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic
export ANTHROPIC_AUTH_TOKEN=<your DeepSeek API Key>
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
cd /path/to/my-project
claudeRun Codex with the Official One-Click Script
The 0731 build of DeepSeek V4 Flash natively supports the OpenAI Responses API[2], which is the protocol Codex speaks. That ends the proxy era: one official script wires up Codex, and it is re-runnable to switch models or restore the original config.
Codex CLI, the ChatGPT desktop app, and the VS Code Codex extension share the same ~/.codex/ configuration. Today only deepseek-v4-flash integrates with Codex; DeepSeek says deepseek-v4-pro support arrives in early August 2026.
The Responses endpoint has no previous_response_id, so multi-turn sessions resend the full context, and OpenAI built-in tools like file_search and code_interpreter are not supported.
- Backs up ~/.codex/config.toml to ~/.codex/backup-deepseek/.
- Writes ~/.codex/models.json declaring the model card: context window 1,048,576, reasoning levels low/high/max, and the apply_patch tool type.
- Adds a [model_providers.deepseek] section to config.toml and keeps your existing MCP and project-trust settings.
- Validates syntax before writing and aborts without touching any file on failure.
- Prompts for your sk- API key on first run.
Prerequisite: install Codex CLI or the ChatGPT desktop app and launch it once so ~/.codex exists before running the script.
# macOS / Linux — run once after installing Codex CLI
bash <(curl -fsSL https://cdn.deepseek.com/api-docs/codex-deepseek-setup-en.sh)
# Windows PowerShell
irm https://cdn.deepseek.com/api-docs/codex-deepseek-setup-en.ps1 | iexUnderstand Model-Name Auto-Mapping
The Anthropic endpoint maps claude-* model names onto DeepSeek models automatically. In most Claude Code sessions you never type a DeepSeek slug at all.
That is why the official env config sets ANTHROPIC_DEFAULT_HAIKU_MODEL to deepseek-v4-flash: Claude Code still routes its internal haiku-tier calls, and DeepSeek serves them with Flash.
The mapping also explains the cost math. Flash carries the haiku tier and sub-agents, so only the main task runs on the more expensive pro model.
| Claude model name | Mapped to | Why it matters |
|---|---|---|
| claude-opus-* | deepseek-v4-pro | Complex, multi-file reasoning |
| claude-sonnet-* / claude-haiku-* | deepseek-v4-flash | Fast, high-frequency work |
| Unrecognized names | deepseek-v4-flash | Safe fallback |
Choose Flash or Pro per Task
Flash and Pro are two tiers of one model family. Flash is the fast, cheap, high-frequency tier; Pro is the flagship for complex reasoning. Pick by task, not by habit.
DeepSeek's own benchmarks, run on its DeepSeek Harness in minimal mode with max effort, put Flash-0731 at 82.7 on Terminal-Bench 2.1 and 54.4 on DeepSWE. The changelog says all nine published agent benchmarks beat V4-Pro-Preview. Treat these as vendor-reported until third parties reproduce them. On the independent Artificial Analysis Intelligence Index v4.1, V4-Flash-0731 scores 50, ranking #2 of 162 models in its price tier.
A typical Cursor Composer run is around 20K input and 3K output tokens: about $0.013 on Pro and $0.003 on Flash. A full day at roughly 150 rounds is about $2 on Pro and under $0.50 on Flash. Community estimates put a $5 top-up at about a week of heavy Flash usage.
| Task type | Model | Price per 1M tokens (input / output) |
|---|---|---|
| Docstrings, test stubs, single-file edits, autocomplete | deepseek-v4-flash | $0.14 / $0.28 |
| Simple agent tasks, chat, web search | deepseek-v4-flash | $0.14 / $0.28 |
| Complex planning, multi-file refactors, hard bugs | deepseek-v4-pro | $0.435 / $0.87 |
| Repeated prompt prefixes (cache hits) | Both | ~98% discount on input |
Concurrency limits are account-level: 2,500 concurrent requests for flash, 500 for pro. In Cursor, your plan's own context ceiling hits before DeepSeek's 1M window.
Fix the Cursor reasoning_content 400
The most time-consuming Cursor issue is the reasoning_content 400 on long agent runs. DeepSeek thinking mode returns both content and reasoning_content in every streaming chunk. Cursor's Chat panel renders both; Composer renders only content and throws HTTP 400 on long tool chains.
The 400 happens because DeepSeek thinking mode requires the next request to replay the full reasoning_content chain. When Cursor packages the next round, it strips that field, so DeepSeek rejects the request. Three fixes exist, from cheapest to most complete.
- Use Chat to read the reasoning and Composer to change files. Zero cost, and the recommended default.
- Turn off thinking mode in Composer or switch to Flash. You lose the reasoning gain, but the agent stays stable.
- Run the community proxy yxlao/deepseek-cursor-proxy[7]. Point Cursor at http://localhost:<port>; the proxy caches the chain-of-thought per session and replays it on the next round. The full Composer agent loop works, and thinking tokens display as collapsed Markdown.
The agent is fully usable once you route around the reasoning replay bug — this is the price of the deepseek-v4-flash thinking mode on this IDE. And remember the legacy aliases deepseek-chat and deepseek-reasoner are gone — any tool config still sending them should switch to deepseek-v4-flash or deepseek-v4-pro.
- [1]Official DeepSeek API Changelog
- [2]Integrate with Codex — Official Docs
- [3]Integrate with Claude Code — Official Docs
- [4]Anthropic API Guide — Official Docs
- [5]DeepSeek Models & Pricing — Official Docs
- [6]Cursor + DeepSeek V4 Setup Guide (Codersera)
- [7]deepseek-cursor-proxy (GitHub)
- [8]awesome-deepseek-agent — Claude Code Config