Problem
When using DeepSeek V4 with thinking mode enabled in OpenCode, you may encounter this error:
The reasoning_content in the thinking mode must be passed back to the API
This happens because:
- DeepSeek V4 returns
reasoning_content (thinking process) in addition to content (final answer)
- In multi-turn conversations with tool calls,
reasoning_content must be passed back to the API
- The
@ai-sdk/openai-compatible package doesn't preserve and pass back reasoning_content
Solution
Use DeepSeek's Anthropic-compatible API instead of the OpenAI-compatible one. The @ai-sdk/anthropic package natively supports reasoning mode (Claude extended thinking).
Configuration
Edit ~/.config/opencode/opencode.json:
"deepseekv4": {
"npm": "@ai-sdk/anthropic",
"name": "DeepSeek",
"options": {
"baseURL": "https://api.deepseek.com/anthropic",
"apiKey": "your-deepseek-api-key"
},
"models": {
"deepseek-v4-pro": {
"name": "DeepSeek-V4-Pro",
"limit": {
"context": 1048576,
"output": 262144
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
}
}
}
}
Key Changes
- npm: Change from
@ai-sdk/openai-compatible to @ai-sdk/anthropic
- baseURL: Change from
https://api.deepseek.com to https://api.deepseek.com/anthropic
- thinking.type: Set to
"enabled" to activate thinking mode
Why This Works
- DeepSeek provides two API formats: OpenAI-compatible and Anthropic-compatible
- The Anthropic SDK has native support for reasoning mode (used by Claude's extended thinking)
- By switching to the Anthropic API format, OpenCode can properly handle
reasoning_content without code changes
Usage
After restarting OpenCode, DeepSeek V4 will work with thinking mode enabled. You'll see the reasoning process in the model's responses.
References
Tested Environment
- OpenCode version: Latest (as of 2026-04-24)
- DeepSeek API: v4-pro
- OS: Windows 11
Problem
When using DeepSeek V4 with thinking mode enabled in OpenCode, you may encounter this error:
This happens because:
reasoning_content(thinking process) in addition tocontent(final answer)reasoning_contentmust be passed back to the API@ai-sdk/openai-compatiblepackage doesn't preserve and pass backreasoning_contentSolution
Use DeepSeek's Anthropic-compatible API instead of the OpenAI-compatible one. The
@ai-sdk/anthropicpackage natively supports reasoning mode (Claude extended thinking).Configuration
Edit
~/.config/opencode/opencode.json:Key Changes
@ai-sdk/openai-compatibleto@ai-sdk/anthropichttps://api.deepseek.comtohttps://api.deepseek.com/anthropic"enabled"to activate thinking modeWhy This Works
reasoning_contentwithout code changesUsage
After restarting OpenCode, DeepSeek V4 will work with thinking mode enabled. You'll see the reasoning process in the model's responses.
References
Tested Environment