結論先說
- 舊模型名已停用,基地址保持
https://api.deepseek.com不變:官方已於 2026-07-24 停用deepseek-chat與deepseek-reasoner;遷至client.responses.create時改用deepseek-flash(支持識圖、預設思考)或deepseek-v4-pro。 - 接口完全無狀態,嚴禁靠
previous_response_id串聯對話:服務端不存儲歷史,previous_response_id與conversation均不支持(響應恆為null);多輪會話須由客戶端維護列表並每次傳入完整input。 - 流式解析必須監聽
response.completed替代data: [DONE]:開啟stream=True後,服務端發送帶sequence_number的語義化 SSE 事件,以response.completed、response.incomplete或response.failed結束,沒有data: [DONE]。 - 思考控制改用
reasoning={"effort": "..."},不支持參數靜默忽略:none關閉思考,low/high/max調深度;store、stream_options、truncation等字段傳了不報錯但也不生效,切勿誤判。 - 需要補充 Codex 原生積分可按需加購加油包:在 Codex 混用原生模型時,已有付費帳號可配本站 Codex 額度積分加油包指南,無底座套餐先看 ChatGPT Plus 開通指南。

圖:本站根據 DeepSeek Responses API 文檔 與 思考模式文檔 整理的示意圖
本文根據 DeepSeek API 官方文檔《使用 Responses API》《思考模式》及《API 概覽》整理,資料核對於 2026-12-03。配圖為本站整理的示意圖,不是介面截圖。本站(bigolab.com)由益陽市赫山區必高科技有限公司獨立運營,是獨立第三方服務商,不是 DeepSeek 或 OpenAI 官方網站。
適用於誰
- 代碼仍保留已停用
deepseek-chat/deepseek-reasoner,需遷至 Responses API 並換用deepseek-flash或deepseek-v4-pro的開發者; - 將
client.chat.completions.create改為client.responses.create時,遇到多輪失憶或流式掛起問題的工程師; - 混用 DeepSeek 與 Codex 工具鏈,需在原生額度吃緊時補充 Codex 原生積分 的研發人員。
一、遷移核心差異與靜默忽略字段表
重構前先對照下表逐項排查參數契約,防止把 OpenAI 有狀態特性直接沿用到 DeepSeek:
| 遷移維度 | 原 Chat Completions | DeepSeek Responses API 規範 | 遷移注意事項 |
|---|---|---|---|
| 接口與模型 | chat.completions + 舊名 | responses.create + deepseek-flash / pro | 禁寫已停用的 chat / reasoner |
| 多輪歷史 | 客戶端傳 messages | 無狀態,完整歷史拼入 input | previous_response_id 恆 null |
| 思考控制 | extra_body={"thinking": ...} | reasoning={"effort": "none/low/high/max"} | 思考態忽略 temperature 等採樣 |
| 流式終結 | 監聽 data: [DONE] | response.completed / incomplete / failed | 無 [DONE],舊解析會掛起 |
| 靜默忽略 | stream_options 等 | store、background、metadata、include、prompt、truncation、service_tier、safety_identifier、prompt_cache_key、context_management、stream_options、parallel_tool_calls、max_tool_calls、reasoning.summary、text.verbosity | 不報錯但無效;超 1M 窗口報 400 |
| 內置工具 | function | function、僅 apply_patch 的 custom、web_search(僅 Pro) | file_search/code_interpreter/mcp 忽略 |

圖:本站根據 DeepSeek Responses API 文檔 整理的示意圖
此外,若舊項目還涉及思考強度微調、文件或圖片多模態輸入,遷移到 Responses 接口時需注意三處細則:第一,深度思考強度除了核心四檔 none、low、high、max 外,還兼容其他工具常見的檔位別名,例如 minimal 會自動映射為 low,medium 與 xhigh 映射為 high,ultra 映射為 max;第二,在 deepseek-flash 上載遞圖片時,內容塊類型須從 image_url 改為 input_image(通過外鏈、數據網址或文件編號三選一傳入,且只能放在用戶或開發者消息中,同時傳外鏈和文件編號會直接觸發 400 報錯);第三,舊版在服務端或中間件依賴並行工具開關時無須再傳 parallel_tool_calls,該能力在遷移後預設始終保持開啟。
二、Python SDK 重構與 SSE 終結事件驗證
以下示例展示無狀態 input 歷史拼接、reasoning.effort 調節,以及用語義事件替代 data: [DONE] 的寫法:
import os
from openai import OpenAI
client = OpenAI(api_key=os.environ["DEEPSEEK_API_KEY"], base_url="https://api.deepseek.com")
history = [] # 客戶端自行儲存完整多輪歷史,切勿傳 previous_response_id
def stream_turn(user_text: str, effort: str = "low") -> str:
history.append({"role": "user", "content": user_text})
chunks = []
stream = client.responses.create(
model="deepseek-flash",
instructions="你是一位嚴謹的後端架構師。",
input=history,
reasoning={"effort": effort}, # none 關思考;別名 medium/xhigh->high, ultra->max
stream=True,
)
for event in stream:
if event.type == "response.output_text.delta":
print(event.delta, end="", flush=True)
chunks.append(event.delta)
elif event.type in ("response.completed", "response.incomplete", "response.failed"):
print(f"\n[SSE 結束事件: {event.type}]")
if event.type != "response.completed":
raise RuntimeError(f"流未完成: {event.type}")
reply = "".join(chunks)
history.append({"role": "assistant", "content": reply})
return reply
stream_turn("列出遷移 Responses API 最易忽略的三個字段。", effort="low")
若使用自定義 HTTP 客戶端或反向代理,上線前用 curl 驗證流末事件序列,確認沒有等待 [DONE] 的阻塞邏輯:
curl -N -sS https://api.deepseek.com/v1/responses \
-H "Content-Type: application/json" -H "Authorization: Bearer $DEEPSEEK_API_KEY" \
-d '{"model":"deepseek-flash","input":"輸出遷移核對一行要點","reasoning":{"effort":"none"},"stream":true}' | grep -E "^event: "
人工核對要點:重構後檢查三項——請求體不含無效 previous_response_id 或 stream_options;流連接在收到 response.completed 後正常釋放;超長曆史由客戶端裁剪防超 1M 報 400。
訂閱與開通提示:在 Codex 混用 DeepSeek 與 OpenAI 原生模型時,如需補充 Codex 原生積分,可在已有付費套餐下選購本站 Codex 250 積分加油包、Codex 500 積分加油包、Codex 1000 積分加油包 或 Codex 2500 積分加油包(須已有 Plus/Pro 付費套餐,Free 免費號勿拍)。全站以商品頁實時標價為準;標價不含稅,開具國內增值稅發票另付 6% 稅費;單獨申請自定義明細電子收據免費。
常見問題
問:為何傳了 store=True 不報錯,下一輪用 previous_response_id 卻找不到記錄?
答:DeepSeek 為兼容既有客戶端採用了「靜默忽略」機制,不會觸發 400,但返回體裏 store 恆為 false、previous_response_id 恆為 null。多輪狀態必須由業務端自建數組並拼入 input。
問:為何設為 reasoning={"effort": "none"} 後 temperature 突然起效?
答:官方思考模式在 low/high/max 下會靜默忽略 temperature、presence_penalty 與 frequency_penalty;僅當設為 none(關閉思考)時,temperature(範圍 0–2)才真正生效。
問:為何傳入除 apply_patch 之外的 custom 工具直接報 400?
答:官方規範規定 custom 工具類型專門兼容 Codex 的 apply_patch,其他名稱會返回 HTTP 400;常規工具調用應寫成 {"type": "function", ...}。
問:還沒有 Plus 或 Pro 套餐,國內怎麼免外幣卡開通並搭配 Codex 加油包?
答:購買積分包前須先備妥付費套餐(Free 號勿拍),可到 AI 訂閱與帳號服務總覽 選購 ChatGPT Plus 信用卡月付 或 ChatGPT Pro 100(10x)iOS 可覆蓋檔,再加購 Codex 額度積分加油包指南 內對應檔位。全站以商品頁實時標價為準;標價不含稅,開具國內增值稅發票另付 6% 稅費;單獨申請電子收據免費。本站明示質保訂閱、不質保封號,請一人一號合規使用。
相關教學
- Pydantic AI對接DeepSeek結構化輸出失敗怎麼辦:Tool模式降級與JSON修復策略
- Ollama跑Qwen3與DeepSeek調用Tool JSON格式飄移怎麼修:Modelfile模板修正
- 企業 AI Agent 調用 MCP 工具怕誤刪數據怎麼辦:人機協同審批流與 OAuth 最小權限
- MCP服務端Sampling與Elicitation怎麼落地:人機交互確認與客戶端兼容避坑
- 個人開發者月預算 300 元怎麼搭 AI 訂閱:Gemini+Claude+DeepSeek 方案
0 條評論
還沒有評論,來搶沙發~