API 目录

创建聊天补全 (非流)

POST
/v1/chat/completions

创建聊天补全(非流式)

POST https://www.vortapapi.com/v1/chat/completions

使用给定的对话消息生成模型回复。该接口兼容 OpenAI Chat Completions 格式,适用于一次性返回完整结果的非流式调用。

请求说明

/chat/completions 发送请求后,Vortap 会根据请求中的模型、消息列表及其他生成参数,返回一个或多个候选回复,并在响应中包含生成结束原因与 token 用量统计等信息。

请求头

名称必填说明
Content-Type请求体格式,通常为 application/json
Accept期望的响应格式,通常为 application/json
AuthorizationAPI 认证信息。建议使用 Bearer sk-***

请求示例

curl https://www.vortapapi.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer sk-***" \
  -d '{
    "model": "your-model-name",
    "messages": [
      {
        "role": "user",
        "content": "你好,请简单介绍一下你自己。"
      }
    ],
    "stream": false
  }'

响应示例

{
  "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
  }
}

响应字段

字段类型说明
idstring本次聊天补全请求的唯一标识
objectstring对象类型,非流式聊天补全通常为 chat.completion
createdinteger响应创建时间,Unix 时间戳
choicesarray模型生成的候选回复列表
choices[].indexinteger当前候选回复在列表中的序号
choices[].messageobject模型返回的消息对象
choices[].message.rolestring消息角色,通常为 assistant
choices[].message.contentstring模型生成的文本内容
choices[].finish_reasonstring生成停止原因,例如 stop
usageobjecttoken 使用统计
usage.prompt_tokensinteger输入消息消耗的 token 数
usage.completion_tokensinteger输出内容消耗的 token 数
usage.total_tokensinteger本次请求消耗的 token 总数