What Is DeepSeek V4-Pro? Models, API, Function Calling & JSON Output Explained • AI / API
What Is DeepSeek V4-Pro? Models, API, Function Calling & JSON Output Explained
You're wiring a DeepSeek Agent and the docs mentiondeepseek-v4-pro,deepseek-v4-flash, and the retireddeepseek-chat. Function Calling sometimes returnsargumentsthat isn't valid JSON—while JSON Mode and Strict Schema follow different paths?
DeepSeek V4-Prois the flagship MoE model in the DeepSeek V4 family, GA since 2026-08-13 (build DeepSeek-V4-Pro-0813). The API surface is unchanged:base_urlstayshttps://api.deepseek.com, setmodeltodeepseek-v4-pro.
It's OpenAI Chat Completions–compatible and also offers an Anthropic-style interface; Function Calling, JSON output, and three thinking effort levels share the same API.
This article covers:
- What V4-Pro and V4-Flash are and how to choose
- A minimal Chat Completions request
- The full Function Calling tool loop
- JSON Mode vs beta Strict Schema
- How JSONNote helps debug model JSON
Keep this in mind:V4-Pro's API looks almost like OpenAI's, buttool_calls[].function.argumentsis still a model-generated JSON string—not guaranteed valid every time. Below we walk through model family → setup → tools → JSON output → choosing a variant.
What is DeepSeek V4-Pro
DeepSeek V4 launched via API on 2026-04-24 as a Mixture-of-Experts stack. V4-Pro is the largest variant: ~1.6T total params, ~49B active per forward pass. The siblingdeepseek-v4-flashis lighter (284B / 13B active) for latency- and cost-sensitive workloads.
The 2026-08-13 GA release significantly boosts Agent skills—official benchmarks like Terminal Bench 2.1 and Toolathlon-Verified report production-grade gains. For developers the practical changes are:
- Multi-step tool calls are steadier, with fewer empty loops before answering
- Native OpenAIResponses APIformat support (Codex-friendly workflows)
- Thinking mode adds
low/high/maxthree effort levels
If you already use the OpenAI SDK with another model, switching to V4-Pro usually means changing onlybase_url,api_key, andmodel.
V4 lineup and legacy names
| API model param | Role | Notes |
|---|---|---|
deepseek-v4-pro |
Flagship Agent / reasoning | 2026-08-13 GA; best for hard tasks |
deepseek-v4-flash |
Fast / economical | 2026-07-31 release; high-QPS friendly |
deepseek-chat(retired) |
legacy | Until 2026-07-24 mapped to V4-Flash non-thinking |
deepseek-reasoner(retired) |
legacy | Until 2026-07-24 mapped to V4-Flash thinking |
New projects and CI scripts should usedeepseek-v4-proordeepseek-v4-flashdirectly—legacy aliases were retired on 2026-07-24.
API essentials
Minimal Chat Completions request
DeepSeek API matches OpenAI Chat Completions. Python example (install theopenaipackage):
from openai import OpenAI
client = OpenAI(
api_key="YOUR_DEEPSEEK_API_KEY",
base_url="https://api.deepseek.com",
)
resp = client.chat.completions.create(
model="deepseek-v4-pro",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "用 JSON 列出三个 HTTP 状态码及含义"},
],
)
print(resp.choices[0].message.content)
Three easy pitfalls
-
1
Stateless API
Every request must include the full
messageshistory. The server won't remember prior tool results for you. -
2
Prompt Cache
Responses
usagemay includeprompt_cache_hit_tokens. Repeated calls with the same prefix hit cache and cost less. -
3
Peak / off-peak pricing
Since 2026-08-16, pricing varies by time slot—off-peak is about half of peak. Batch jobs can be scheduled accordingly.
Function Calling end-to-end
Function Calling lets the model return structured tool invocations—query a database, call HTTP, run math—instead of guessing. V4-Pro uses OpenAI-styletoolsarrays.
1. Define tools (JSON Schema)
{
"type": "function",
"function": {
"name": "get_order",
"description": "按订单号查询订单状态",
"parameters": {
"type": "object",
"properties": {
"order_id": { "type": "string", "description": "例如 ORD-10442" }
},
"required": ["order_id"]
}
}
}
2. Model returns tool_calls
When the model wants a tool,finish_reasonis"tool_calls",message.contentis usually empty—the real instruction lives in thetool_callsarray:
{
"choices": [{
"message": {
"role": "assistant",
"content": "",
"tool_calls": [{
"id": "call_0_f1c29a44",
"type": "function",
"function": {
"name": "get_order",
"arguments": "{\"order_id\": \"ORD-10442\"}"
}
}]
},
"finish_reason": "tool_calls"
}]
}
Note:argumentsis astringyou mustjson.loadsyourself. Official docs warn the model doesn't always emit valid JSON and may hallucinate fields outside your schema.
3. Execute and return a tool message
import json
messages = [{"role": "user", "content": "查一下 ORD-10442 的状态"}]
tools = [/* 上面的 get_order 定义 */]
resp = client.chat.completions.create(
model="deepseek-v4-pro",
messages=messages,
tools=tools,
)
msg = resp.choices[0].message
if msg.tool_calls:
messages.append(msg) # 保留 assistant 的 tool_calls
call = msg.tool_calls[0]
try:
args = json.loads(call.function.arguments)
except json.JSONDecodeError:
args = {} # 降级或重试
result = get_order(**args) # 你的业务函数
messages.append({
"role": "tool",
"tool_call_id": call.id,
"content": json.dumps(result, ensure_ascii=False),
})
# 再次请求,模型基于真实数据生成最终回答
final = client.chat.completions.create(
model="deepseek-v4-pro",
messages=messages,
tools=tools,
)
tool_choice behavior
| tool_choice | Meaning | Typical use |
|---|---|---|
"auto"(default) |
Model decides whether to call tools | General Agents |
"none" |
Disallow tool calls | Plain-text answers, control tests |
{"type":"function","function":{"name":"…"}} |
Force a specific function | Pipeline step that must hit one tool |
max_tokensToo small aargumentstruncates tool-callfinish_reasonbecomeslengthwith incomplete arguments. Agent workloads need generous completion budgets.
JSON output and Strict mode
JSON Mode (response_format)
When you only need JSON text—not external tools—use JSON Mode:
resp = client.chat.completions.create(
model="deepseek-v4-pro",
messages=[
{"role": "system", "content": "只输出合法 JSON,不要 markdown 代码块"},
{"role": "user", "content": "生成一个含 name、age 的用户对象"},
],
response_format={"type": "json_object"},
)
raw = resp.choices[0].message.content
data = json.loads(raw) # 仍建议 try/except
DeepSeek raised internal JSON parse rates from 78% to 85% in the V2 era; regex cleanup can reach 97%. V4 improves further, butalways validate in your application—don't treat a successfuljson.loadsas proof the schema is correct.
Strict Schema (beta)
For Function Calling that must match JSON Schema exactly, enable beta Strict mode:
base_urlChangehttps://api.deepseek.com/beta- Set
"strict": true - Every
objectobject'spropertiesmust list all keys inrequired, withadditionalProperties: false
Strict validates atrequest time—invalid schemas return 400 before generation. Good for catching schema bugs at deploy time.
JSON Mode vs Function Calling
| Capability | JSON Mode | Function Calling |
|---|---|---|
| Trigger | response_format: json_object |
toolsarray + tool loop |
| Output location | message.content |
tool_calls[].function.arguments |
| Can call external systems | No—JSON text only | Yes—your code runs then returns results |
| Strict schema | Prompt + post-processing | beta Strict native support |
Three thinking effort levels
V4-Pro and V4-Flash thinking modes supportlow / high / maxeffort tiers (seeofficial API docsThinking Mode section):
- low: simple Q&A, formatting, short summaries
- high: daily Agents, multi-step reasoning
- max: complex code generation, long planning
Thinking costs more tokens and latency. For “turn this text into JSON,” non-thinking mode + JSON Mode is usually cheaper.
V4-Pro vs V4-Flash
| Dimension | V4-Pro | V4-Flash |
|---|---|---|
| Params (total / active) | ~1.6T / ~49B | ~284B / ~13B |
| Agent / tool calling | GA boost; best for complex chains | 0731 release beats Pro Preview on Agent benches |
| Latency & cost | Higher | Lower; good for high QPS |
| Function Calling | Supported | Supported |
| JSON output | Supported | Supported |
| Typical scenarios | Production Agents, repo ops, heavy analytics | Chatbots, batch extraction, prototypes |
Both share the same API—A/B tests only need amodelchange. A common rollout: prove the tool chain on Flash, upgrade to Pro when needed.
Debug model JSON with JSONNote
Integrating V4-Pro means lots of time asking “does this JSON parse, does the schema match?” JSONNote runs locally in the browser—your API key and response bodies never upload.
-
1
Format & validate
Paste
message.contentortool_calls[].function.argumentsintoJSON FormatterorJSON Validatorto see syntax errors instantly. -
2
Check against Schema
In theJSON Schematool, paste your function parameters schema and model output to verify fields.
-
3
Diff two calls
After tweaking prompts or switching Pro / Flash, useJSON Diffto compare structured outputs.
-
4
Share with teammates
UseURL Hash sharingto encode failing JSON and tool state in a link—recipients reproduce locally; data never hits our servers.
FAQ
What is the DeepSeek V4-Pro API model name?
deepseek-v4-pro.base_urlishttps://api.deepseek.com, auth matches OpenAI (Authorization: Bearer …).
How do I choose between V4-Pro and V4-Flash?
Complex Agents, long context, high tool accuracy → Pro. High concurrency, cost-sensitive, standard tasks → Flash. Both support Function Calling and JSON output.
What if Function Calling returns malformed JSON?
Wrap parsing intry/except json.JSONDecodeError; validate required fields; retry or fall back to JSON Mode; use beta Strict when you need strict adherence.
Do I still need my own schema with JSON Mode?
JSON Mode only guarantees a JSON object—not that fields match your business schema. Enforce shape via system prompt, post-validation, or Function Calling + Strict.
Can I still use deepseek-chat?
No. Legacy names retired 2026-07-24. Migrate todeepseek-v4-proordeepseek-v4-flash.
How does Function Calling differ from OpenAI gpt-4o?
Request/response fields and tool loops are largely compatible. Differences: pricing, context length, thinking tiers, and DeepSeek's Strict beta path. Regression-testargumentsparsing andmax_tokensbudgets when migrating.
Summary
DeepSeek V4-Pro is essentially:
OpenAI-compatible API + flagship MoE + native Function Calling / JSON output + optional thinking effort.
Setmodeltodeepseek-v4-pro, write tool loops the OpenAI way, but remember:argumentsis model-generated—parse and validate on your side. JSONNote's formatter, Schema, and Diff tools help debug structured output locally.
下一步尝试