创建思考聊天
POST/v1/messages 创建带思考过程的聊天消息
POST https://www.vortapapi.com/v1/messages
通过该接口提交对话消息,并让模型生成回复。适用于需要模型进行更深入推理、规划或分析的场景。Vortap API 网关兼容 OpenAI 风格的响应结构,返回结果中包含生成内容、结束原因以及 token 使用量等信息。
请求头
| 名称 | 必填 | 说明 |
|---|---|---|
Content-Type | 是 | 请求体格式,通常为 application/json |
Accept | 是 | 响应格式,通常为 application/json |
Authorization | 否 | API 认证信息,例如 Bearer sk-*** |
请求示例
curl https://www.vortapapi.com/v1/messages \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Authorization: Bearer sk-***" \
-d '{
"model": "your-model-name",
"messages": [
{
"role": "user",
"content": "请逐步思考并解释这个问题。"
}
]
}'
响应示例
{
"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
}
}
响应字段说明
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 本次生成结果的唯一标识 |
object | string | 对象类型,通常为 chat.completion |
created | integer | 响应创建时间,Unix 时间戳 |
choices | array | 模型生成的候选回复列表 |
choices[].index | integer | 当前候选回复的序号 |
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 数 |