Featured image of post How to Fix DeepSeek Model Reasoning Issues in OpenCode

How to Fix DeepSeek Model Reasoning Issues in OpenCode

Troubleshooting and resolving the "reasoning_content must be passed back to the API" error when using opencode with deepseek-reasoner.

语速

When using deepseek-reasoner, we often encounter this problem:

1
The reasoning_content' in the thinking mode must be passed back to the API.

Update

Both issues have now been officially resolved by opencode. Users only need to install the latest version of opencode and use it through the deepseek provider, without additional configuration.

1
2
3
4
5
6
Issue 1
The reasoning_content' in the thinking mode must be passed back to the API.

Issue 2
Bad Request: {"error":{"message":"The content[].thinking in the thinking mode must be passed back to the 
API.","type":"invalid_request_error","param":null,"code":"invalid_request_error"}}

Both issues have been officially resolved. Install version 1.14.29 or above.


The old solution follows:

How to solve it? It’s straightforward.

How to Configure

Add provider information to your configuration:

.config/opencode/opencode.json or .config/opencode/opencode.jsonc

Modify the provider section to:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
{
    "provider": {
        "deepseek": {
            "npm": "@ai-sdk/anthropic",
            "name": "DeepSeek",
            "options": {
                "baseURL": "https://api.deepseek.com/anthropic",
                "apiKey": "<apikey>"
            },
            "models": {
                "deepseek-v4-pro": {
                    "name": "DeepSeek-V4-Pro",
                    "limit": {
                        "context": 1048576,
                        "output": 262144
                    },
                    "options": {
                        "thinking": {
                            "type": "enabled",
                            "budgetTokens": 8192
                        }
                    }
                },
                "deepseek-v4-flash": {
                    "name": "DeepSeek-V4-Flash",
                    "limit": {
                        "context": 1048576,
                        "output": 262144
                    },
                    "options": {
                        "thinking": {
                            "type": "enabled",
                            "budgetTokens": 8192
                        }
                    }
                }
            }
        }
     }
}

How to Use

Select the deepseek model.

The result.

Supplement

This method cannot solve this problem

Bad Request: {"error":{"message":"The content[].thinking in the thinking mode must be passed back to the API.","type":"invalid_request_error","param":null,"code":"invalid_request_error"}}

If you encounter this problem, you need to wait for opencode to fix it.

Related article: DeepSeek + Claude Code: Thinking Block Compatibility Issue Analysis — Analyzes the root cause of 400 errors triggered by multi-turn conversations in extended thinking mode when using DeepSeek with Claude Code, along with community solutions.