Skip to content

参考

基于 DeepSeek 官方 API 文档(api-docs.deepseek.com)+ GitHub deepseek-ai 仓库编写,对照 V3.1 / V3.2 / V4 系列

速查

  • 三条 Base URLhttps://api.deepseek.com(OpenAI 兼容)/ /anthropic(Anthropic 格式)/ /beta(FIM + Strict Function Calling)
  • 核心端点POST /chat/completions(会话)/ POST /completions(FIM 填空)
  • 模型 ID(V3.1 双约定)deepseek-chat(非思考)/ deepseek-reasoner(思考);V4 合并为 deepseek-v4-flash / deepseek-v4-pro + thinking 开关
  • thinking{type: enabled|disabled} 默认 enabled;reasoning_efforthigh | max(agent 自动 max)
  • 思考模式失效参数temperature / top_p / presence_penalty / frequency_penalty
  • Context Caching:默认开启;prompt_cache_hit_tokens / prompt_cache_miss_tokens;命中价约低 98%
  • JSON Outputresponse_format={type: json_object};prompt 必含 'json' + 结构示例
  • FIM/beta + POST /completions + prompt + suffixmax_tokens 上限 4K
  • Strict Function Calling/beta + 每 function strict:trueobject 必须 additionalProperties:false 且全 required
  • 完整说明见 入门 / 核心 API 与最佳实践

完整 Base URL 速查

Base URL用途备注
https://api.deepseek.comOpenAI 兼容(主端点)推荐,复用 OpenAI SDK 生态
https://api.deepseek.com/anthropicAnthropic 格式兼容V3.1 新增,复用 Anthropic SDK
https://api.deepseek.com/betaBeta 功能(FIM + Strict Function Calling)仍在演进,注意稳定性

模型 ID 与模式映射

模型 ID模式系列用途
deepseek-chat非思考V3.x(V3.1 起约定)通用对话、写文案、轻度代码
deepseek-reasoner思考(CoT)R1数学、逻辑、复杂代码、Agent
deepseek-v4-flash单模型 + thinking 开关V4轻量场景,可动态切思考
deepseek-v4-pro单模型 + thinking 开关V4复杂场景,思考/非思考合并

V3.1:双 ID 约定(deepseek-chat / deepseek-reasoner,同一权重 deepseek-ai/DeepSeek-V3.1)。V4:合并为单模型 + thinking 参数。

thinking 与 reasoning_effort

参数取值默认说明
thinking.typeenabled / disabledenabled思考开关
reasoning_efforthigh / maxhigh推理强度;low/mediumhighxhighmax;agent 场景自动 max
python
# OpenAI SDK 走 extra_body
client.chat.completions.create(
    model="deepseek-v4-pro",
    messages=[...],
    extra_body={"thinking": {"type": "enabled"}, "reasoning_effort": "max"},
)

思考模式失效参数(关键约束)

thinking 启用时,下列参数官方明说不生效(仅为兼容旧软件保留入参):

参数思考模式行为
temperature不生效(思考模式由模型自主采样)
top_p不生效
presence_penalty不生效
frequency_penalty不生效

R1 在非思考模式下仍可用 temperature 0.5–0.7(推荐 0.6)、top_p 0.95 的官方推荐采样。

响应字段

python
{
    "choices": [{
        "message": {
            "role": "assistant",
            "content": "可见回答",
            "reasoning_content": "推理链(思考模式)",  # 与 content 同级
            "tool_calls": [...]                        # 触发工具调用时
        }
    }],
    "usage": {
        "prompt_tokens": 100,
        "completion_tokens": 200,
        "reasoning_tokens": 150,             # 思考消耗
        "prompt_cache_hit_tokens": 800,      # Context Cache 命中
        "prompt_cache_miss_tokens": 100      # Context Cache 未命中
    }
}

功能矩阵

功能端点 / 参数关键约束
会话补全POST /chat/completionsOpenAI SDK 直接用
思考模式thinking: {type: enabled}失效 temp/top_p/penalties
Context Caching默认开启best-effort,TTL 几小时~几天
JSON Outputresponse_format={type: json_object}prompt 必含 'json';偶发空内容
Function Callingtools 数组标准 OpenAI 协议
Strict Function Calling(Beta)/beta + strict:trueobject additionalProperties:false + 全 required
FIM 填空补全(Beta)/beta + POST /completions + prompt + suffixmax_tokens 上限 4K
流式响应stream: truedelta.reasoning_content 单独推送

R1 推理最佳采样(官方 README)

参数推荐值说明
temperature0.6(范围 0.5–0.7)官方复现基准的最佳值
top_p0.95与 temperature 配合
system prompt不要放所有指令塞 user prompt
答案格式放进 \boxed{}数学题推荐

蒸馏版矩阵

DistillBase 模型AIME 2024License
DeepSeek-R1-Distill-Qwen-1.5BQwen2.528.9MIT + Qwen License
DeepSeek-R1-Distill-Qwen-7BQwen2.555.5MIT + Qwen License
DeepSeek-R1-Distill-Llama-8BLlama-3.150.4MIT + Llama 3.1 License
DeepSeek-R1-Distill-Qwen-14BQwen2.569.7MIT + Qwen License
DeepSeek-R1-Distill-Qwen-32BQwen2.572.6(反超 o1-mini 63.6)MIT + Qwen License
DeepSeek-R1-Distill-Llama-70BLlama-3.370.0MIT + Llama 3.3 License

蒸馏版用 800K 样本 SFT,不走 RL;选型需叠加 base 模型上游 License。

版本演进时间线

时间版本关键事件
2024 末DeepSeek-V3671B 总参 / 37B 激活 MoE,128K 上下文,14.8T tokens,2.788M H800 GPU 小时
2025-01-20DeepSeek-R1首个开源长 CoT 推理模型,基于 V3-Base + 纯 RL + 冷启动,MIT,对标 OpenAI o1
2025-01-20DeepSeek-R1-Zero纯 RL(无 SFT)参考版,验证推理涌现
2025-08-21DeepSeek-V3.1Hybrid Inference「一模型两模式」:deepseek-chat / deepseek-reasoner;新增 Anthropic API 格式 + Strict Function Calling Beta
2025-09~12DeepSeek-V3.2Thinking 集成进 tool-use;V3.2-Speciale 在 IMO/CMO/ICPC/IOI 2025 夺金
2026deepseek-v4-flash / v4-pro思考/非思考合并为单一模型 + thinking 开关;`reasoning_effort=high

R1 关键 Benchmark

BenchmarkDeepSeek-R1对标
AIME 202479.8Pass@1(o1-1217: 79.2)
MATH-50097.3
Codeforces Rating2029(96.3 百分位)
LiveCodeBench65.9
MMLU90.8o1-1217: 91.8(略低)
GPQA-Diamond71.5o1: 75.7(略低)
SWE-Verified49.2Claude-3.5-Sonnet: 50.8(略低)

R1 强在数学/代码/推理,通用知识与软件工程并非最强。

V3 架构关键数字

数字
总参数671B
激活参数(每 token)37B(MoE)
上下文128K
预训练 tokens14.8T
训练成本2.788M H800 GPU 小时
关键架构MLA + DeepSeekMoE + 无辅助损失负载均衡 + MTP

反模式速查

反模式后果
思考场景调 deepseek-chat拿不到推理链
V4 接口仍写死 deepseek-reasoner调用失败或行为不一致
多轮 tool-call 丢 reasoning_content直接 400
给 R1 加 system prompt影响推理链质量
思考模式设 temperature空操作,误导调试
FIM 不切 /beta失败
FIM max_tokens > 4K截断或失败
Strict 漏 additionalProperties:false服务端报错
JSON 模式不预估 max_tokens偶发空内容
把 R1 当全场景最强通用/软件工程任务劣于 o1/Claude

官方资源