聊天補全
核心對話端點,相容 OpenAI Chat Completions 格式。支援多模態輸入、串流輸出、工具呼叫與推理模型。
請求
curl https://console.dotouch.ltd/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-your-token" \
-d '{
"model": "deepseek-v4-1-flash-261017",
"messages": [
{ "role": "system", "content": "You are a concise assistant" },
{ "role": "user", "content": "Hello" }
],
"stream": false
}'
请求REQUEST
POST
https://console.dotouch.ltd/v1/chat/completions响应RESPONSE
填写参数并发送请求,响应会显示在这里
請求主體參數
| 參數 | 類型 | 必填 | 說明 |
|---|---|---|---|
model | string | 是 | 模型名稱,見 列出模型 |
messages | array | 是 | 對話訊息陣列,見下方訊息結構 |
stream | boolean | 否 | 串流輸出(SSE),預設 false |
temperature | number | 否 | 取樣溫度 0–2,預設 1——越低越穩定 |
top_p | number | 否 | 核心取樣;與 temperature 擇一調整即可 |
max_tokens | number | 否 | 最大生成 token 數(較新的模型改用 max_completion_tokens) |
stop | string / array | 否 | 停止序列,最多 4 個 |
tools | array | 否 | 工具(函式)定義,見工具呼叫 |
tool_choice | string / object | 否 | auto / none / required / 指定工具 |
response_format | object | 否 | {"type": "json_object"} 或 {"type": "json_schema", ...} |
seed | integer | 否 | 隨機種子,用於重現輸出 |
frequency_penalty | number | 否 | -2.0–2.0,降低重複 |
presence_penalty | number | 否 | -2.0–2.0,鼓勵新話題 |
reasoning_effort | string | 否 | 推理模型的推理強度:low / medium / high |
user | string | 否 | 終端使用者識別碼,便於風控監控 |
訊息結構
| 欄位 | 類型 | 說明 |
|---|---|---|
role | string | system / user / assistant / tool |
content | string / array | 字串,或多模態內容陣列(見多模態輸入) |
name | string | 選填,參與者名稱 |
tool_calls | array | assistant 訊息中模型發起的工具呼叫 |
tool_call_id | string | tool 訊息必填——對應正在回覆的呼叫 |
回應(非串流)
{
"id": "chatcmpl-B3xK1abc123",
"object": "chat.completion",
"created": 1730000000,
"model": "deepseek-v4-1-flash-261017",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 20,
"completion_tokens": 12,
"total_tokens": 32
}
}
| 欄位 | 說明 |
|---|---|
choices[].message.content | 模型的回覆 |
choices[].finish_reason | stop 正常結束 / length 達到 token 上限 / tool_calls 需要執行工具 |
usage | token 用量——計費依據 |
usage.completion_tokens_details.reasoning_tokens | 推理模型回傳的思考 token 數 |