POST/v1/chat/completions
Chat Completions
对话补全。GPT-5.4 等模型默认侧重推理:用 reasoning_effort 控制推理深度(如 none / low / medium / high / xhigh,具体取值因模型而异),用 verbosity 控制答复详略,用 max_completion_tokens 限制总生成量(含推理 token)。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| model | string | ✓ | 模型 ID,例如 gpt-5.3-chat、gpt-5.4、claude-haiku-4-5(以控制台/API Key 绑定为准) |
| messages | array | ✓ | 消息数组:role(system / user / assistant / tool)与 content |
| reasoning_effort | string | — | 推理强度。官方枚举含 none、minimal、low、medium、high、xhigh 等;不同模型支持的集合不同(如 gpt-5.4 默认 none,可至 xhigh)。更低延迟用 none/low,复杂任务用 medium/high/xhigh。 |
| verbosity | string | — | 输出详略:low / medium / high(Chat Completions 顶层字段,与官方参考一致)。 |
| max_completion_tokens | integer | — | 生成 token 上限,包含可见输出与推理 token;推理模型优先使用本字段(max_tokens 已逐步被替代且与部分 o/推理模型不兼容)。 |
| temperature | number | — | 新版 GPT-5.2 / GPT-5.4 在 reasoning_effort ≠ none 时不支持,请求将失败;仅在与官方兼容的旧模型或 reasoning_effort 为 none 时使用。 |
| top_p | number | — | 与 temperature 相同限制:旗舰推理模型在 reasoning_effort ≠ none 时不可用。 |
| stream | boolean | — | 是否 SSE 流式返回 |
| tools | array | — | Function Calling 工具定义 |
| tool_choice | string | object | — | 工具选择策略 |
| response_format | object | — | 如 { "type": "json_object" } |
curl -X POST {API_BASE}/v1/chat/completions \
-H "Authorization: Bearer {API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.4",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
],
"reasoning_effort": "medium",
"verbosity": "medium",
"max_completion_tokens": 2048
}'{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1700000000,
"model": "gpt-5.4",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 20,
"completion_tokens": 9,
"total_tokens": 29
}
}