Skip to content

Vision

Pass images inside messages to analyze them with multimodal models.

POST/v1/chat/completions

Vision (image input) is not a separate endpoint — it works inside the messages of /v1/chat/completions. Images are not a top-level parameter; instead you build messages[].content as an array of content parts and place the image inside it. As long as the routed model supports vision, it just works — there is no separate enablement flag.

Request#

Replace content with an array of parts instead of a string. The available part types are {"type": "text", "text": "..."} for text and {"type": "image_url", "image_url": {"url": "..."}} for images.

The url can be a public https image URL. OpenAI and Google models receive it as native passthrough, and when routed to an Anthropic (Claude) model the router converts it automatically.

image_url (https)
curl https://apirouter.pleum.ai/v1/chat/completions \
  -H "Authorization: Bearer $PLEUM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {
        "role": "user",
        "content": [
          {"type": "text", "text": "What is in this image?"},
          {
            "type": "image_url",
            "image_url": {
              "url": "https://example.com/photo.png"
            }
          }
        ]
      }
    ]
  }'

Instead of an external URL, you can inline the image as a base64 data URL (data:image/png;base64,...). Common formats such as PNG, JPEG, WebP, and GIF are supported.

image_url (base64 data URL)
{
  "model": "gpt-4o",
  "messages": [
    {
      "role": "user",
      "content": [
        {"type": "text", "text": "Describe this diagram."},
        {
          "type": "image_url",
          "image_url": {
            "url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
          }
        }
      ]
    }
  ]
}

Per-model support#

Vision only works when the routed model supports image input. The GET /v1/modelsresponse does not currently distinguish per-model vision support, so check the provider's model documentation. Sending an image to a model without vision support returns an error.

Response#

The response uses the same format as a regular chat completion. Images are counted as input tokens by the model and added to usage.prompt_tokens, with the cost reflected in cost.

200 OK
{
  "id": "chatcmpl-gpt-4o-1204ms",
  "object": "chat.completion",
  "model": "gpt-4o",
  "provider": "openai",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "The image shows a red bicycle leaning against a brick wall."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 1124,
    "completion_tokens": 16,
    "total_tokens": 1140
  },
  "cost": {
    "usd": 0.003012,
    "krw": 5,
    "fx_rate": 1525.0,
    "markup_rate": 0.0
  }
}
Adding "cache_control": {"type": "ephemeral"} to a part only affects Anthropic (Claude) (explicit caching). OpenAI, Gemini, and DeepSeek auto-cache and ignore this marker.