Skip to content
Fresh 2026

Documents

How to send PDF documents as base64 or URL to document-capable models, with supported model list.

Gateway supports sending PDF documents to models with document input capability. Pass documents as base64-encoded data or a URL - Gateway handles the provider-specific format translation.

Send a document (base64)

python
import base64

with open("report.pdf", "rb") as f:
    pdf_data = base64.standard_b64encode(f.read()).decode("utf-8")

response = client.responses.create(
    model="anthropic/claude-sonnet-4-20250514",
    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)
typescript
import { readFileSync } from "fs";

const pdfData = readFileSync("report.pdf").toString("base64");

const response = await client.responses.create({
  model: "anthropic/claude-sonnet-4-20250514",
  input: [
    {
      type: "message",
      role: "user",
      content: [
        { type: "text", text: "Summarize this document." },
        {
          type: "document",
          source_type: "base64",
          media_type: "application/pdf",
          data: pdfData,
        },
      ],
    },
  ],
});

console.log(response.output[0].content[0].text);

Send a document (URL)

python
response = client.responses.create(
    model="google/gemini-2.0-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",
                },
            ],
        }
    ],
)

Supported models

Document input is supported by models with "document" in their capabilities.input array. Check model capabilities via GET /v1/models.

ProviderModels
AnthropicClaude Sonnet 4, Claude Haiku 3.5
GoogleGemini 2.0 Flash, Gemini 2.5 Pro

Documents are estimated at ~1,500 tokens per page for compression calculations. A 10-page PDF counts as roughly 15,000 tokens toward the context window.

Unofficial documentation reference. Built for internal use.