跳轉到主要內容
把圖像作為 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 形式呈現。具體數值請查閱上游當前的視覺文檔。