跳转到主要内容
把图像作为 type: "image_url" 的内容片段发送。传一个公网可达的 https:// URL——这是兼容性最高的方式。 data:image/...;base64,... 的内联 URI 对 OpenAI 和 Gemini 目标有效。 对 Anthropic 和 xAI Grok 模型,发送 base64 时建议改用 https:// 托管的图像 URL,或使用服务商的原生 HTTP 形态 (见原生格式)。
resp = client.chat.completions.create(
    model="openai/gpt-4o-mini",
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "What's in this image?"},
            {"type": "image_url", "image_url": {"url": "https://example.com/cat.jpg"}},
        ],
    }],
)

支持视觉的模型家族

视觉能在所有接受图像输入的上游模型上工作。例如:
  • OpenAI gpt-4o*gpt-4.1* 系列
  • Anthropic Claude 4 系列(当前所有模型)
  • Google Gemini 多模态(gemini-{2.5,3,3.1}-{flash,pro}
  • xAI Grok 4 系列(视觉内置于通用的 Grok 4 chat 模型)

尺寸限制

每个上游服务商对每张图都有自己的尺寸上限(内联 base64 通常在个位数 MB 区间,托管 URL 则更高)。OrcaRouter 透传上游的限制,超过会以 来自上游的 400 形式呈现。具体数值请查阅上游当前的视觉文档。