跳到主要内容

ChatCompletions格式

POST /v1/chat/completions

请求参数​

参数名类型必选说明
modelstring必选模型 ID
messagesarray<object>必选对话消息列表
messages[].rolestring必选消息角色
messages[].contentstring | array<object>必选消息内容
messages[].namestring可选发送者名称
messages[].tool_callsarray<object>可选-
messages[].tool_calls[].idstring可选-
messages[].tool_calls[].typestring可选-
messages[].tool_calls[].functionobject可选-
messages[].tool_call_idstring可选工具调用 ID(用于 tool 角色消息)
messages[].reasoning_contentstring可选推理内容
temperaturenumber可选采样温度
top_pnumber可选核采样参数
ninteger可选生成数量
streamboolean可选是否流式响应
stream_optionsobject可选-
stream_options.include_usageboolean可选-
stopstring | array<string>可选停止序列
max_tokensinteger可选最大生成 Token 数
max_completion_tokensinteger可选最大补全 Token 数
presence_penaltynumber可选-
frequency_penaltynumber可选-
logit_biasobject可选-
userstring可选-
toolsarray<object>可选-
tools[].typestring可选-
tools[].functionobject可选-
tools[].function.namestring可选-
tools[].function.descriptionstring可选-
tools[].function.parametersobject可选JSON Schema 格式的参数定义
tool_choicestring | object可选-
response_formatobject可选-
response_format.typestring可选-
response_format.json_schemaobject可选JSON Schema 定义
seedinteger可选-
reasoning_effortstring可选推理强度 (用于支持推理的模型)
modalitiesarray<string>可选-
audioobject可选-
audio.voicestring可选-
audio.formatstring可选-

请求示例​

{
"body": {
"model": "gpt-4",
"messages": [
{
"role": "system",
"content": "string"
}
]
}
}

响应字段(200)​

字段名类型说明
modelstringp p-0 模型 ID
messagesarray<object>p p-0 对话消息列表
messages[].rolestringp p-0 消息角色
messages[].contentstring | array<object>p p-0 消息内容
messages[].namestringp p-0 发送者名称
messages[].tool_callsarray<object>-
messages[].tool_calls[].idstring-
messages[].tool_calls[].typestring-
messages[].tool_calls[].functionobject-
messages[].tool_call_idstringp p-0 工具调用 ID(用于 tool 角色消息)
messages[].reasoning_contentstringp p-0 推理内容
temperaturenumberp p-0 采样温度
top_pnumberp p-0 核采样参数
nintegerp p-0 生成数量
streambooleanp p-0 是否流式响应
stream_optionsobject-
stream_options.include_usageboolean-
stopstring | array<string>p p-0 停止序列
max_tokensintegerp p-0 最大生成 Token 数
max_completion_tokensintegerp p-0 最大补全 Token 数
presence_penaltynumber-
frequency_penaltynumber-
logit_biasobject-
logit_bias.[key: string]number-
userstring-
toolsarray<object>-
tools[].typestring-
tools[].functionobject-
tools[].function.namestring-
tools[].function.descriptionstring-
tools[].function.parametersobjectp p-0 JSON Schema 格式的参数定义
tool_choicestring | object-
response_formatobject-
response_format.typestring-
response_format.json_schemaobjectp p-0 JSON Schema 定义
seedinteger-
reasoning_effortstringp p-0 推理强度 (用于支持推理的模型)
modalitiesarray<string>-
audioobject-
audio.voicestring-
audio.formatstring-