Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.crazyrouter.com/llms.txt

Use this file to discover all available pages before exploring further.

聊天识图

POST /v1/chat/completions
Crazyrouter 生产环境已验证支持 OpenAI 风格 image_url 输入的常用模型:
  • gpt-4ogpt-4o-minigpt-4.1gpt-5.4 等 OpenAI 视觉模型
  • 输入支持 data:image/...;base64,... data URL 与公网 https:// URL 两种形式
  • 返回的 message.content 当前是普通字符串
推荐顺序:本地图先用 图片上传接口 转成 media.crazyrouter.com 临时 URL,再传入 image_url;或直接发送 base64 data URL。远程公网 URL 也可用,但要满足下文”远程 URL 限制”。

用 base64 data URL(最稳)

curl https://crazyrouter.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "gpt-4o-mini",
    "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": 100
  }'
返回示例:
{
  "model": "gpt-4o-mini",
  "choices": [
    {
      "message": {
        "role": "assistant",
        "content": "Red."
      }
    }
  ]
}

用远程 https URL

curl https://crazyrouter.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [
      {
        "role": "user",
        "content": [
          {"type": "text", "text": "Describe in 5 words."},
          {
            "type": "image_url",
            "image_url": {
              "url": "https://www.gstatic.com/webp/gallery/1.jpg"
            }
          }
        ]
      }
    ],
    "max_tokens": 40
  }'

远程 URL 限制

URL 必须是 Crazyrouter 服务端可访问的图片地址,仅”浏览器能打开”是不够的。常见失败原因:
失败模式原因解决方法
域名无法解析私网地址、拼写错误改用公网 https URL
403 Forbidden部分 CDN(如 wikimedia、私有 S3)限制服务端 UA / Referer改走 图片上传接口 或 base64
Content-Type 非 image/*URL 返回 HTML 页面或重定向到登录页确认 URL 直链可下载
文件超过 20MB单文件大小限制压缩或裁剪后上传
如果你看到错误信息 Unable to process the image you provided. Please verify the image URL is publicly accessible, or upload it as base64.,说明 URL 在服务端不可达,按上表排查。

推荐做法

  • 内部素材、私有图、不确定可达性的图:先调 POST /v1/files/uploads 拿到 media.crazyrouter.com/... 的 72 小时临时 URL,再传给 image_url
  • 体积小(< 1MB)或一次性图:直接 base64 data URL,避免一次额外的上传请求
  • 多图、detail 参数等高级用法:当前 OpenAI 上游均支持,按 OpenAI 官方协议传即可