TokAPI Docs

图像分析

使用标准的图像内容块将图片发送给支持视觉的模型。

图像分析没有专门的接口 —— 你只需在普通请求中发送图像内容块。支持视觉的模型包括 Claude Opus / Sonnet / Haiku 以及 GPT 模型(输入模态:textimagepdf)。

Claude —— POST /v1/messages

发送一个 image 内容块,可使用 URL 或 base64 source:

curl https://api.tokapi.ai/v1/messages \
  -H "Authorization: Bearer sk-lazytech-..." \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-6",
    "max_tokens": 512,
    "messages": [{
      "role": "user",
      "content": [
        { "type": "text", "text": "描述这张图片里你看到的内容。" },
        { "type": "image", "source": { "type": "url", "url": "https://example.com/photo.jpg" } }
      ]
    }]
  }'

OpenAI 兼容 —— POST /v1/chat/completions

使用 image_url 内容部分:

{ "type": "image_url", "image_url": { "url": "https://example.com/photo.jpg" } }

Base64 图片

也接受 base64 数据 URL。对于 Claude,使用带 media_typebase64 source:

{
  "type": "image",
  "source": {
    "type": "base64",
    "media_type": "image/jpeg",
    "data": "<base64-编码的字节>"
  }
}

On this page