ChatCompletions格式
POST /v1/chat/completions
请求参数
| 参数名 | 类型 | 必选 | 说明 |
|---|---|---|---|
model | string | 必选 | 模型 ID |
messages | array<object> | 必选 | 对话消息列表 |
messages[].role | string | 必选 | 消息角色 |
messages[].content | string | array<object> | 必选 | 消息内容 |
messages[].name | string | 可选 | 发送者名称 |
messages[].tool_calls | array<object> | 可选 | - |
messages[].tool_calls[].id | string | 可选 | - |
messages[].tool_calls[].type | string | 可选 | - |
messages[].tool_calls[].function | object | 可选 | - |
messages[].tool_call_id | string | 可选 | 工具调用 ID(用于 tool 角色消息) |
messages[].reasoning_content | string | 可选 | 推理内容 |
temperature | number | 可选 | 采样温度 |
top_p | number | 可选 | 核采样参数 |
n | integer | 可选 | 生成数量 |
stream | boolean | 可选 | 是否流式响应 |
stream_options | object | 可选 | - |
stream_options.include_usage | boolean | 可选 | - |
stop | string | array<string> | 可选 | 停止序列 |
max_tokens | integer | 可选 | 最大生成 Token 数 |
max_completion_tokens | integer | 可选 | 最大补全 Token 数 |
presence_penalty | number | 可选 | - |
frequency_penalty | number | 可选 | - |
logit_bias | object | 可选 | - |
user | string | 可选 | - |
tools | array<object> | 可选 | - |
tools[].type | string | 可选 | - |
tools[].function | object | 可选 | - |
tools[].function.name | string | 可选 | - |
tools[].function.description | string | 可选 | - |
tools[].function.parameters | object | 可选 | JSON Schema 格式的参数定义 |
tool_choice | string | object | 可选 | - |
response_format | object | 可选 | - |
response_format.type | string | 可选 | - |
response_format.json_schema | object | 可选 | JSON Schema 定义 |
seed | integer | 可选 | - |
reasoning_effort | string | 可选 | 推理强度 (用于支持推理的模型) |
modalities | array<string> | 可选 | - |
audio | object | 可选 | - |
audio.voice | string | 可选 | - |
audio.format | string | 可选 | - |
请求示例
{
"body": {
"model": "gpt-4",
"messages": [
{
"role": "system",
"content": "string"
}
]
}
}
响应字段(200)
| 字段名 | 类型 | 说明 |
|---|---|---|
model | string | p p-0 模型 ID |
messages | array<object> | p p-0 对话消息列表 |
messages[].role | string | p p-0 消息角色 |
messages[].content | string | array<object> | p p-0 消息内容 |
messages[].name | string | p p-0 发送者名称 |
messages[].tool_calls | array<object> | - |
messages[].tool_calls[].id | string | - |
messages[].tool_calls[].type | string | - |
messages[].tool_calls[].function | object | - |
messages[].tool_call_id | string | p p-0 工具调用 ID(用于 tool 角色消息) |
messages[].reasoning_content | string | p p-0 推理内容 |
temperature | number | p p-0 采样温度 |
top_p | number | p p-0 核采样参数 |
n | integer | p p-0 生成数量 |
stream | boolean | p p-0 是否流式响应 |
stream_options | object | - |
stream_options.include_usage | boolean | - |
stop | string | array<string> | p p-0 停止序列 |
max_tokens | integer | p p-0 最大生成 Token 数 |
max_completion_tokens | integer | p p-0 最大补全 Token 数 |
presence_penalty | number | - |
frequency_penalty | number | - |
logit_bias | object | - |
logit_bias.[key: string] | number | - |
user | string | - |
tools | array<object> | - |
tools[].type | string | - |
tools[].function | object | - |
tools[].function.name | string | - |
tools[].function.description | string | - |
tools[].function.parameters | object | p p-0 JSON Schema 格式的参数定义 |
tool_choice | string | object | - |
response_format | object | - |
response_format.type | string | - |
response_format.json_schema | object | p p-0 JSON Schema 定义 |
seed | integer | - |
reasoning_effort | string | p p-0 推理强度 (用于支持推理的模型) |
modalities | array<string> | - |
audio | object | - |
audio.voice | string | - |
audio.format | string | - |