You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 15, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on May 15, 2026. It is now read-only.
[ENHANCEMENT] Request to support DeepSeek V4 flash and V4 pro models #12173
Opened PR #12175 with my attempt at adding deepseek-v4-flash and deepseek-v4-pro support, including optional thinking mode with reasoning_effort parameter. Feedback welcome! #12175
It's important to note that the Thinking Mode is enabled by default in the Deepseek API. Therefore, you need to explicitly declare the Thinking Mode on/off switch and the thinking intensity in your request ({"thinking": {"type": "enabled/disabled"}}, {"reasoning_effort": "high/max"}).
Also, please note that unlike rounds in Thinking Mode where no tool calls are made, rounds in which tool calls are made must return the complete reasoning_content to the API in all subsequent requests. If your code does not return reasoning_content correctly, the API will return a 400 error.
Below is a simple example code for making tool calls in Thinking Mode:
importosimportjsonfromopenaiimportOpenAIfromdatetimeimportdatetime# The definition of the toolstools= [
{
"type": "function",
"function": {
"name": "get_date",
"description": "Get the current date",
"parameters": { "type": "object", "properties": {} },
}
},
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get weather of a location, the user should supply the location and date.",
"parameters": {
"type": "object",
"properties": {
"location": { "type": "string", "description": "The city name" },
"date": { "type": "string", "description": "The date in format YYYY-mm-dd" },
},
"required": ["location", "date"]
},
}
},
]
# The mocked version of the tool callsdefget_date_mock():
returndatetime.now().strftime("%Y-%m-%d")
defget_weather_mock(location, date):
return"Cloudy 7~13°C"TOOL_CALL_MAP= {
"get_date": get_date_mock,
"get_weather": get_weather_mock
}
defrun_turn(turn, messages):
sub_turn=1whileTrue:
response=client.chat.completions.create(
model='deepseek-v4-pro',
messages=messages,
tools=tools,
reasoning_effort="high",
extra_body={ "thinking": { "type": "enabled" } },
)
messages.append(response.choices[0].message)
reasoning_content=response.choices[0].message.reasoning_contentcontent=response.choices[0].message.contenttool_calls=response.choices[0].message.tool_callsprint(f"Turn {turn}.{sub_turn}\n{reasoning_content=}\n{content=}\n{tool_calls=}")
# If there is no tool calls, then the model should get a final answer and we need to stop the loopiftool_callsisNone:
breakfortoolintool_calls:
tool_function=TOOL_CALL_MAP[tool.function.name]
tool_result=tool_function(**json.loads(tool.function.arguments))
print(f"tool result for {tool.function.name}: {tool_result}\n")
messages.append({
"role": "tool",
"tool_call_id": tool.id,
"content": tool_result,
})
sub_turn+=1print()
client=OpenAI(
api_key=os.environ.get('DEEPSEEK_API_KEY'),
base_url=os.environ.get('DEEPSEEK_BASE_URL'),
)
# The user starts a questionturn=1messages= [{
"role": "user",
"content": "How's the weather in Hangzhou Tomorrow"
}]
run_turn(turn, messages)
# The user starts a new questionturn=2messages.append({
"role": "user",
"content": "How's the weather in Guangzhou Tomorrow"
})
run_turn(turn, messages)
Activity
binggee9526 commentedon Apr 24, 2026
There are informations of DeepSeek V4 model. @roomote
deepseek-v4-flashanddeepseek-v4-pro.thinking: { type: "enabled" }parameter as the current reasoner of V4 mode.The parameterreasoningcan selecthighormax.It's deault ashigh. ref https://api-docs.deepseek.com/{ "model": "deepseek-v4-pro", "messages": [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Hello!"} ], "thinking": {"type": "enabled"}, "reasoning_effort": "high", "stream": false }3.about price and contex
for
deepseek-v4-flash:1M INPUT TOKENS (CACHE MISS) | $0.14
1M OUTPUT TOKENS | $0.28
for
deepseek-v4-pro:1M INPUT TOKENS (CACHE MISS) | $1.74
1M OUTPUT TOKENS | $3.48
ref https://api-docs.deepseek.com/quick_start/pricing
JiayunLi-3E8 commentedon Apr 24, 2026
It's important to note that the Thinking Mode is enabled by default in the Deepseek API. Therefore, you need to explicitly declare the Thinking Mode on/off switch and the thinking intensity in your request ({"thinking": {"type": "enabled/disabled"}}, {"reasoning_effort": "high/max"}).
Also, please note that unlike rounds in Thinking Mode where no tool calls are made, rounds in which tool calls are made must return the complete
reasoning_contentto the API in all subsequent requests. If your code does not returnreasoning_contentcorrectly, the API will return a 400 error.Below is a simple example code for making tool calls in Thinking Mode:
MaxOTS commentedon Apr 26, 2026
It is due to https://api-docs.deepseek.com/guides/thinking_mode
https://github.com/dirac-run/dirac works well with the new deepseek models