What is Thinking Mode
The DeepSeek V4 series (Flash and Pro) both support Thinking Mode, a major breakthrough in DeepSeek's reasoning capabilities. When Thinking Mode is enabled, the model performs an internal chain-of-thought analysis before generating the final answer, similar to the Chain-of-Thought mechanism in OpenAI o1/o3, but DeepSeek offers it as an optional feature—a single model supports both non-thinking and thinking modes, easily switched via parameters.
Enabling Thinking Mode
Controlled via the thinking parameter:
from openai import OpenAI
import os
client = OpenAI(
api_key=os.environ.get('DEEPSEEK_API_KEY'),
base_url='https://api.deepseek.com'
)
response = client.chat.completions.create(
model='deepseek-v4-pro',
messages=[
{'role': 'system', 'content': 'You are a helpful assistant'},
{'role': 'user', 'content': 'Please prove that the square root of 2 is irrational'}
],
extra_body={'thinking': {'type': 'enabled'}},
reasoning_effort='high'
)
print('Thinking process:', response.choices[0].message.reasoning_content)
print('Final answer:', response.choices[0].message.content)Detailed Explanation of reasoning_effort Levels
| Level | Effect | Token Consumption | Use Cases |
|---|---|---|---|
| low | Fast reasoning, lightweight thinking | Minimal | Simple math problems, common sense judgments |
| medium | Default level, balances speed and depth | Moderate | Moderate complexity reasoning, code debugging |
| high | Deep reasoning, most complete chain of thought | Maximum | Mathematical proofs, complex logic, competition problems |
Extracting and Displaying the Chain of Thought
The thinking content is located in the reasoning_content field. For frontend display, it is recommended to collapse it into an expandable area:
// Node.js example
import OpenAI from 'openai';
const openai = new OpenAI({
baseURL: 'https://api.deepseek.com',
apiKey: process.env.DEEPSEEK_API_KEY,
});
const completion = await openai.chat.completions.create({
messages: [
{ role: 'system', content: 'You are a math expert' },
{ role: 'user', content: 'Solve the equation x2 - 5x + 6 = 0' }
],
model: 'deepseek-v4-flash',
thinking: { type: 'enabled' },
reasoning_effort: 'medium',
});
console.log('Reasoning chain:', completion.choices[0].message.reasoning_content);
console.log('Answer:', completion.choices[0].message.content);Dual-Mode Switching Strategy
The best practice is to dynamically choose the mode based on the task type:
- Non-thinking mode: Daily conversation, translation, summarization, simple Q&A—faster and cheaper
- Thinking mode: Mathematics, programming, logical reasoning, complex analysis—quality first
- Strategy: Use non-thinking mode for quick responses first; if the answer quality is insufficient, automatically upgrade to thinking mode and retry
Pricing Rules
Tokens generated in thinking mode are divided into two categories: reasoning tokens (reasoning_content) are billed at input prices, and output tokens (content) are billed at output prices. The reasoning token price for V4 Flash thinking mode is ¥1/million tokens, and for V4 Pro it is ¥3/million tokens.
Notes
- FIM completion only supports non-thinking mode
- reasoning_content in thinking mode needs to be parsed separately
- In streaming output, thinking content is also returned in chunks
- It is recommended to set an appropriate reasoning_effort based on task complexity to avoid waste