ChatCompletions格式
更新时间:2026-11-04
POST
根据对话历史创建模型响应。支持流式和非流式响应。兼容 OpenAI Chat Completions API。
BearerAuthheader
AuthorizationBearer <token>使用 API Key 认证,格式:Authorization: Bearer <token>。
application/json- body
model*string模型 ID,如 kimi-k3。
messages*array<>对话消息列表,每项含 role、content,role 可为 system / user / assistant 等。
temperature?number采样温度。
范围
0 <= value <= 2默认值
1top_p?number核采样参数。
范围
0 <= value <= 1默认值
1n?integer生成数量。
范围
1 <= value默认值
1stream?boolean是否流式响应。
默认值
falsestream_options?流式响应选项。
stop?|array<string>停止序列。
max_tokens?integer最大生成 Token 数。
max_completion_tokens?integer最大补全 Token 数。
presence_penalty?number存在惩罚。
范围
-2 <= value <= 2默认值
0frequency_penalty?number频率惩罚。
范围
-2 <= value <= 2默认值
0logit_bias?Logit 偏置。
user?string终端用户标识。
tools?array<>工具定义。
tool_choice?|工具选择策略。
response_format?响应格式,如 JSON 模式。
seed?integer随机种子。
reasoning_effort?string推理强度(用于支持推理的模型)。
可选值
"low""medium""high"modalities?array<string>输出模态。
audio?音频输出配置。
成功创建响应
application/json- response
id?string响应 ID。
object?string对象类型。
created?integer创建时间,Unix 时间戳(秒)。
model?string实际使用的模型 ID。
choices?array<>生成结果列表。
usage?Token 用量统计。
system_fingerprint?string后端配置指纹。
curl -X POST 'https://vod.gz.baidubce.com/v1/chat/completions' \ -H 'Content-Type: application/json' \ -d '{ "model": "kimi-k3", "messages": [ { "role": "system", "content": "string" } ]}'响应示例
{ "id": "string", "object": "string", "created": 0, "model": "string", "choices": [ { "index": 0, "message": { "role": "string", "content": "string", "name": "string", "tool_calls": [ { "id": "string", "type": "string", "function": { "name": "string", "arguments": "string" } } ], "tool_call_id": "string", "reasoning_content": "string" }, "finish_reason": "string" } ], "usage": { "prompt_tokens": 0, "completion_tokens": 0, "total_tokens": 0, "prompt_tokens_details": { "cached_tokens": 0, "text_tokens": 0, "audio_tokens": 0, "image_tokens": 0 }, "completion_tokens_details": { "text_tokens": 0, "audio_tokens": 0, "reasoning_tokens": 0 } }, "system_fingerprint": "string"}
