控制推理模型努力程度
POST/v1/chat/completions 控制推理模型的推理强度
POST https://www.vortapapi.com/v1/chat/completions
通过 Chat Completions 接口发送对话请求时,可以为支持推理能力的模型设置推理强度。推理强度会影响模型在回答前投入的思考量:强度越高,通常推理更充分,但响应时间和 token 消耗也可能增加。
请求头
| 名称 | 必填 | 说明 |
|---|---|---|
Content-Type | 是 | 请求体格式,通常为 application/json |
Accept | 是 | 响应格式,通常为 application/json |
Authorization | 否 | API 密钥,例如 Bearer sk-*** |
X-Forwarded-Host | 否 | 透传的原始主机信息,通常无需手动设置 |
请求体参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 要调用的模型名称。 |
messages | array | 是 | 对话消息列表。 |
reasoning_effort | string | 否 | 控制推理模型的思考强度。常见取值包括 low、medium、high。 |
stream | boolean | 否 | 是否以流式方式返回结果。 |
请求示例
curl https://www.vortapapi.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Authorization: Bearer sk-***" \
-d '{
"model": "reasoning-model",
"messages": [
{
"role": "user",
"content": "请解释为什么天空是蓝色的。"
}
],
"reasoning_effort": "medium"
}'
响应示例
{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1677652288,
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "\n\nHello there, how may I assist you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 9,
"completion_tokens": 12,
"total_tokens": 21
}
}
推理强度说明
| 值 | 说明 |
|---|---|
low | 使用较少推理步骤,适合简单问题或对延迟敏感的场景。 |
medium | 默认均衡设置,兼顾响应质量、速度和成本。 |
high | 投入更多推理计算,适合复杂分析、数学推导、代码规划等任务。 |
返回字段说明
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 本次补全请求的唯一标识。 |
object | string | 对象类型,Chat Completions 响应通常为 chat.completion。 |
created | integer | 响应创建时间,Unix 时间戳格式。 |
choices | array | 模型生成的候选结果列表。 |
choices[].index | integer | 当前候选结果在列表中的序号。 |
choices[].message | object | 模型返回的消息内容。 |
choices[].message.role | string | 消息角色,通常为 assistant。 |
choices[].message.content | string | 模型生成的文本内容。 |
choices[].finish_reason | string | 生成结束原因,例如 stop。 |
usage | object | token 使用统计。 |
usage.prompt_tokens | integer | 输入提示消耗的 token 数。 |
usage.completion_tokens | integer | 输出内容消耗的 token 数。 |
usage.total_tokens | integer | 本次请求总 token 数。 |