Documentation

ChatCompletions格式

Last updated: Nov 4, 2026

POST
/v1/chat/completions

根据对话历史创建模型响应。支持流式和非流式响应。兼容 OpenAI Chat Completions API。

Authorization

BearerAuth
headerAuthorizationBearer <token>

使用 API Key 认证,格式:Authorization: Bearer <token>。

Request Body

application/json
  1. body
model*string

模型 ID,如 kimi-k3。

messages*array<>

对话消息列表,每项含 role、content,role 可为 system / user / assistant 等。

temperature?number

采样温度。

Range0 <= value <= 2
Default1
top_p?number

核采样参数。

Range0 <= value <= 1
Default1
n?integer

生成数量。

Range1 <= value
Default1
stream?boolean

是否流式响应。

Defaultfalse
stream_options?

流式响应选项。

stop?|array<string>

停止序列。

max_tokens?integer

最大生成 Token 数。

max_completion_tokens?integer

最大补全 Token 数。

presence_penalty?number

存在惩罚。

Range-2 <= value <= 2
Default0
frequency_penalty?number

频率惩罚。

Range-2 <= value <= 2
Default0
logit_bias?

Logit 偏置。

user?string

终端用户标识。

tools?array<>

工具定义。

tool_choice?|

工具选择策略。

response_format?

响应格式,如 JSON 模式。

seed?integer

随机种子。

reasoning_effort?string

推理强度(用于支持推理的模型)。

Value in"low""medium""high"
modalities?array<string>

输出模态。

audio?

音频输出配置。

Response Body

成功创建响应

application/json
  1. response
id?string

响应 ID。

object?string

对象类型。

created?integer

创建时间,Unix 时间戳(秒)。

model?string

实际使用的模型 ID。

choices?array<>

生成结果列表。

usage?

Token 用量统计。

system_fingerprint?string

后端配置指纹。

Example Request
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"    }  ]}'
Example Response
{  "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"}