> This page is for Gateway.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.merge.dev/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.merge.dev/_mcp/server.

# Images

> Send images to vision-capable models on Gateway with the image_url or image content block, the OpenAI SDK, or AI SDK file parts.

Send images with your prompt to have a model describe, compare, or extract from them. Use `image_url` for a URL or `data:` URI, or `image` for raw base64; Gateway converts either to the served vendor's format.

**`cURL`**

```bash title="cURL"
curl https://api-gateway.merge.dev/v1/responses \
  -H "Authorization: Bearer $MERGE_GATEWAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-5.1",
    "input": [{
      "type": "message",
      "role": "user",
      "content": [
        {"type": "text", "text": "Compare these two product shots."},
        {"type": "image_url", "url": "https://example.com/before.jpg"},
        {"type": "image_url", "url": "https://example.com/after.jpg"}
      ]
    }]
  }'
```

**`Python`**

```python title="Python"
import base64, os
from merge_gateway import MergeGateway

client = MergeGateway(api_key=os.environ["MERGE_GATEWAY_API_KEY"])

with open("photo.png", "rb") as f:
    image_data = base64.standard_b64encode(f.read()).decode()

response = client.responses.create(
    model="anthropic/claude-sonnet-5",
    input=[{
        "type": "message",
        "role": "user",
        "content": [
            {"type": "text", "text": "What do you see?"},
            {"type": "image", "source_type": "base64", "media_type": "image/png", "data": image_data},
        ],
    }],
)
print(response.output[0].content[0].text)
```

**`AI SDK`**

```typescript title="AI SDK"
import { createMergeGateway } from "merge-gateway-ai-sdk-provider";
import { generateText } from "ai";
import { readFileSync } from "fs";

const gateway = createMergeGateway({ apiKey: process.env.MERGE_GATEWAY_API_KEY });

const { text } = await generateText({
  model: gateway("openai/gpt-5.1"),
  messages: [{
    role: "user",
    content: [
      { type: "text", text: "What do you see?" },
      { type: "file", mediaType: "image/png", data: readFileSync("photo.png") },
    ],
  }],
});
console.log(text);
```

With the OpenAI SDK at `/v1/openai`, send the standard `{"type": "image_url", "image_url": {"url": "..."}}` part, or `input_image` on Responses. AI SDK file parts take `data` as bytes, base64, a `data:` URI, or a URL.

> **Note**
>
> AI SDK file parts need `merge-gateway-ai-sdk-provider` 0.3.0 or later; earlier versions drop them silently.

## Reference

| Field               | Notes                                                 |
| ------------------- | ----------------------------------------------------- |
| `image_url.url`     | An `https://` URL or a `data:` URI                    |
| `image.source_type` | `base64` (default) or `url`                           |
| `image.media_type`  | Required, even for a URL, such as `image/png`         |
| `image.data`        | Base64 string, or the URL when `source_type` is `url` |

Inline images are capped at 20 MB decoded per request, all images combined; URLs don't count. Over the cap returns `413 payload_too_large`, and a route without image input returns `400 unsupported_params`.

## Next steps

#### [Documents](/merge-gateway/capabilities/multimodal/documents)

Send PDFs to document-capable models

#### [Image generation](/merge-gateway/capabilities/multimodal/image-generation)

Generate images from a prompt