DeepSeek-V4-Flash — 對話補全

用 OpenAI 相容協議呼叫 DeepSeek-V4-Flash。

POST /v1/chat/completions

请求体

modelstringrequired要呼叫的模型名, 填模型廣場裡的名稱。
messagesarrayrequired對話訊息列表, 每項含 role 與 content。role 可為 system / user / assistant / tool。
    rolestringrequired
    contentstringrequired訊息內容 (字串, 或多模態陣列 `[{"type":"text","text":"..."},{"type":"image_url","image_url":{"url":"..."}}]`)
    namestring(可選) 訊息作者標識
    tool_call_idstring(僅 role=tool) 對應的 tool_call id
streamboolean是否流式返回。true 時以 SSE 逐塊推送, 適合需要邊生成邊展示的場景。
temperaturenumber取樣溫度, 越大輸出越發散、越小越穩定。
max_tokensinteger本次回覆最多生成多少 token。不傳則由模型自行決定, 不會被截斷。
top_pnumber核取樣, 只在累計機率前 top_p 的候選裡挑。與 temperature 選一個調即可。
toolsarray可供模型呼叫的工具列表。模型需要時會返回 tool_calls, 由你執行後把結果以 role=tool 回填。
tool_choicestring控制是否/如何選用工具: auto 由模型決定, none 停用, 也可指定某個具體工具。需與 tools 一起使用。
response_formatobject指定輸出格式, 如要求返回 JSON。
stoparray遇到其中任一字串就停止生成, 該字串不包含在結果裡。
ninteger一次返回幾條候選回覆。按全部候選的總用量計費。
seedinteger固定隨機種子, 相同輸入儘量復現相同輸出。
frequency_penaltynumber按 token 已出現頻次降低其再次出現的機率, 用於抑制重複。
presence_penaltynumber按 token 是否已出現降低其再次出現的機率, 用於鼓勵換話題。
logit_biasobject按 token id 調整選中機率, 可用來強推或壓制特定詞。
parallel_tool_callsboolean是否允許模型一次返回多個工具呼叫。需與 tools 一起使用。
logprobsboolean是否返回所選 token 的對數機率。
top_logprobsinteger每個位置額外返回多少個候選 token 的機率。需同時開啟 logprobs。
max_completion_tokensinteger回覆長度上限。部分較新模型用這個欄位替代 max_tokens。
reasoning_effortstring推理強度。調高會讓模型思考更久、通常更準, 同時消耗更多 token。僅推理類模型有效。
verbositystring回覆詳略程度。
modalitiesarray期望的輸出模態, 如僅文本或文本加音訊。僅多模態模型有效。
audioobject音訊輸出設定, 如音色與音訊格式。需在 modalities 中包含音訊。
predictionobject預測輸出。已知回覆大部分內容時提供它可以加快生成。
stream_optionsobject流式相關設定, 如是否在最後一幀附帶用量統計。需 stream=true。
storeboolean是否在模型服務側留存本次對話。
metadataobject自定義鍵值對, 會隨請求一起帶上, 便於你自己歸類檢索。
userstring代表終端使用者的標識, 便於你區分自己的使用者來源。
prompt_cache_keystring提示詞快取鍵。相同字首的請求帶同一個鍵更容易命中快取, 從而更快更省。
prompt_cache_retentionstring提示詞快取保留時長。

响应

调用示例

curl https://api.router.ai/v1/chat/completions \
  -H "Authorization: Bearer sk-你的令牌" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v4-flash",
    "messages": [{"role": "user", "content": "你好"}]
  }'

API 文件