LLM Gateway
Features

Vision Support

Learn how to send images to vision-enabled models using URLs or inline base64 data.

LLMGateway supports vision-enabled models that can analyze and describe images. You can provide images via HTTPS URLs or inline base64-encoded data.

Vision-Enabled Models

You can find all vision-enabled models on our models page with vision filter. These models can process both text and image content in the same request.

Image Formats

Using HTTPS URLs

You can provide any publicly accessible HTTPS URL pointing to an image:

curl -X POST "https://api.llmgateway.io/v1/chat/completions" \
  -H "Authorization: Bearer $LLM_GATEWAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "What do you see in this image?"
          },
          {
            "type": "image_url",
            "image_url": {
              "url": "https://example.com/image.jpg"
            }
          }
        ]
      }
    ]
  }'

Using Base64 Inline Data

You can also provide images as base64-encoded data URIs:

curl -X POST "https://api.llmgateway.io/v1/chat/completions" \
  -H "Authorization: Bearer $LLM_GATEWAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "Describe this image"
          },
          {
            "type": "image_url",
            "image_url": {
              "url": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD..."
            }
          }
        ]
      }
    ]
  }'

Content Array Format

When using vision models, the content field should be an array containing both text and image content blocks:

  • Text content: {"type": "text", "text": "Your message"}
  • Image content: {"type": "image_url", "image_url": {"url": "image_url_or_data_uri"}}

Multiple Images

You can include multiple images in a single request:

curl -X POST "https://api.llmgateway.io/v1/chat/completions" \
  -H "Authorization: Bearer $LLM_GATEWAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "Compare these two images"
          },
          {
            "type": "image_url",
            "image_url": {
              "url": "https://example.com/image1.jpg"
            }
          },
          {
            "type": "image_url",
            "image_url": {
              "url": "https://example.com/image2.jpg"
            }
          }
        ]
      }
    ]
  }'

Simple String Content

For vision models, you can still use simple string content for text-only messages. The array format is only required when including images.

curl -X POST "https://api.llmgateway.io/v1/chat/completions" \
  -H "Authorization: Bearer $LLM_GATEWAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {
        "role": "user",
        "content": "Hello! How can you help me today?"
      }
    ]
  }'

Supported Image Types

Vision models typically support common image formats including:

  • JPEG (.jpg, .jpeg)
  • PNG (.png)
  • WebP (.webp)
  • GIF (.gif)

The specific formats supported may vary by model provider. Check the individual model documentation for format limitations and file size restrictions.

Error Handling

When the gateway downloads an image before sending it to a provider, the download has a 15-second deadline covering hostname validation, response headers and the entire body. A timeout returns HTTP 400 with Timed out fetching image from URL; the image is not forwarded or replaced with a placeholder. Redirects and private-network URLs are rejected.

Self-hosted deployments can override the deadline with IMAGE_FETCH_TIMEOUT_MS, a positive integer in milliseconds up to 2147483647. Unset, blank, zero, negative, fractional, or out-of-range values use the 15-second default.

How is this guide?

Last updated on

On this page

Ready for production?

Ship to production with SSO, audit logs, spend controls, and guardrails your security team will approve.

Explore Enterprise