图像分析
使用标准内容块将图像发送给支持视觉的模型。
图像分析没有专门的端点。你在普通请求中发送图像内容块即可。支持视觉的模型包括
Opus、Sonnet、Haiku,以及 GPT 模型(输入模态 text, image, pdf)。
Claude(/v1/messages)
发送带 URL 或 base64 source 的 image 内容块:
curl https://api.tryarcflow.com/v1/messages \
-H "Authorization: Bearer sk-..." \
-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": "Describe what you see in this image." },
{ "type": "image", "source": { "type": "url", "url": "https://example.com/photo.jpg" } }
]
}]
}'OpenAI 兼容(/v1/chat/completions)
改用 image_url 内容部分:
{ "type": "image_url", "image_url": { "url": "https://example.com/photo.jpg" } }base64 图像
两种接口都接受 base64 编码的图像。对于 Claude,使用 source.type: "base64"
并带上 media_type:
{
"type": "image",
"source": {
"type": "base64",
"media_type": "image/jpeg",
"data": "<base64-encoded bytes>"
}
}对于 OpenAI 兼容接口,在 image_url.url 中传入 data: URL。