API 目录

识图接口 [Chat 兼容格式]

POST
/v1/chat/completions

识图接口(Chat 兼容格式)

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

该接口用于通过 Chat Completions 兼容格式提交包含图片的对话请求。模型会根据输入的文本与图像内容生成回复,可用于图片理解、视觉问答、图像描述等场景。

请求头

名称必填说明
Content-Type请求体格式,通常为 application/json
Accept期望的响应格式,通常为 application/json
AuthorizationAPI Key,格式为 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-vision-model",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "请描述这张图片的内容。"
          },
          {
            "type": "image_url",
            "image_url": {
              "url": "https://example.com/image.jpg"
            }
          }
        ]
      }
    ]
  }'

响应示例

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