跳转到主要内容

Claude 识图

截至 2026 年 3 月 23 日,Crazyrouter 生产环境已验证两条 Claude 视觉输入路径:
  • 原生 POST /v1/messages + type: "image" + Base64 PNG
  • OpenAI 兼容 POST /v1/chat/completions + type: "image_url" + data URL

原生格式:/v1/messages

curl https://crazyrouter.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-sonnet-4-6",
    "max_tokens": 128,
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "image",
            "source": {
              "type": "base64",
              "media_type": "image/png",
              "data": "iVBORw0KGgoAAA..."
            }
          },
          {
            "type": "text",
            "text": "What color is this image?"
          }
        ]
      }
    ]
  }'
本次生产环境检查返回了:
  • model: "claude-sonnet-4-6"
  • content[0].type = "text"

OpenAI 兼容格式:/v1/chat/completions

curl https://crazyrouter.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "claude-sonnet-4-6",
    "messages": [
      {
        "role": "user",
        "content": [
          {"type": "text", "text": "What color is this image?"},
          {
            "type": "image_url",
            "image_url": {
              "url": "data:image/png;base64,iVBORw0KGgoAAA..."
            }
          }
        ]
      }
    ],
    "max_tokens": 128
  }'
2026-03-23 的生产环境实测里,模型返回的 message.content 是普通字符串,内容为对图片颜色的文本描述。
当前页面只保留 Base64 PNG / data URL 这两条已复测成功的视觉输入方式。远程 URL、更多图片格式与更复杂多图场景,本轮没有逐项复测。