> 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.

# Documents

> Send PDF documents to document-capable models on Gateway as base64 or a URL with the document content block or AI SDK file parts.

Send a PDF with your prompt to have a model summarize, answer questions about, or extract from it. Pass it as base64 or a URL in a `document` block; Gateway converts it 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": "google/gemini-3.6-flash",
    "input": [{
      "type": "message",
      "role": "user",
      "content": [
        {"type": "text", "text": "What are the key findings?"},
        {"type": "document", "source_type": "url", "media_type": "application/pdf", "data": "https://example.com/report.pdf"}
      ]
    }]
  }'
```

**`Python`**

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

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

with open("report.pdf", "rb") as f:
    pdf_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": "Summarize this document."},
            {"type": "document", "source_type": "base64", "media_type": "application/pdf", "data": pdf_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("anthropic/claude-sonnet-5"),
  messages: [{
    role: "user",
    content: [
      { type: "text", text: "Summarize this document." },
      { type: "file", mediaType: "application/pdf", filename: "report.pdf", data: readFileSync("report.pdf") },
    ],
  }],
});
console.log(text);
```

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

## Reference

| Field         | Notes                                                 |
| ------------- | ----------------------------------------------------- |
| `source_type` | `base64` (default) or `url`                           |
| `media_type`  | Required, such as `application/pdf`                   |
| `data`        | Base64 string, or the URL when `source_type` is `url` |

Inline documents are capped at 20 MB decoded per request, all documents combined; URLs don't count. Over the cap returns `413 payload_too_large`, and a route without document input returns `400 unsupported_params`. Filter by document input in the [model catalog](/merge-gateway/models/catalog).

## Next steps

#### [Images](/merge-gateway/capabilities/multimodal/images)

Send images to a vision-capable model

#### [Multimodal overview](/merge-gateway/capabilities/multimodal/overview)

Every modality, endpoint, and surface