cross-backend-file-attachment · EN · 2026-10-27

Attaching a PDF Through One Aggregator Key: Which Backends Read the Text Layer and Which Only See the First Page

This guide explains how a PDF is handled when sent through a unified API aggregator that routes to different model backends. It covers which backends can read the PDF's text layer versus those that only process the first page, and provides practical strategies for reliable PDF ingestion across providers.

How PDFs Reach Different Backends

When you send a PDF to a model through a single aggregator API key, the aggregator routes the request to a specific backend. The backend's native PDF handling determines what part of the document the model can actually see.

Backends fall into two broad categories:

  • Native PDF readers that extract the text layer (and sometimes layout) from multiple pages.
  • First-page-only processors that convert only the first page to an image or extract text from page one.

Understanding these differences helps you avoid truncated or missing content.

Backends That Read the Text Layer

Some backends are built to accept PDFs directly and parse the embedded text layer. They can typically handle multi-page documents and may also preserve basic structure like headings and lists.

Examples of native PDF support include certain models from Anthropic (Claude) and some OpenAI models when used with the right input format. These backends read the text layer rather than rendering pages as images, so they work best with digitally created PDFs (not scanned images).

If your PDF is text-based and the backend is a native reader, you can usually send the PDF file as-is and the model will process all pages.

Backends That Only See the First Page

Other backends do not natively accept PDFs as a document type. Instead, the aggregator (or the provider's gateway) may convert the PDF by extracting only the first page's text or by rendering the first page as an image. In these cases, the model never sees page two and beyond.

First-page-only handling is common when:

  • The model is text-only and the PDF is converted to plain text.
  • The model is multimodal but the PDF is converted to a single image.
  • The provider's API does not support PDF input and falls back to a preview.

If you send a multi-page PDF to a first-page-only backend, you will get responses based solely on the first page, which can lead to incomplete or misleading answers.

How to Check What a Backend Supports

Before sending a PDF, verify the backend's capabilities:

  • Check the model documentation in the aggregator's docs for supported input types (PDF, image, text).
  • Test with a known multi-page PDF and ask a question whose answer appears only on page two or later.
  • Observe the response—if the model cannot answer, it likely doesn't see beyond page one.

Because the aggregator routes to different providers, support can vary even within the same model family. Always confirm per backend.

Strategies for Reliable PDF Ingestion

If you need consistent results across backends, consider these approaches:

  • Extract text yourself using a PDF library and send the text as a prompt. This guarantees the model sees all pages, regardless of backend.
  • Split the PDF into single-page documents and send each page separately, then combine results.
  • Use a native PDF reader backend when you need layout or visual understanding, and ensure it supports multi-page input.
  • Avoid scanned PDFs with native text-layer readers; they require OCR first.

For scanned PDFs, run OCR and send the extracted text.

Choosing the Right Backend for Your PDF Task

Your choice depends on the task:

  • Text-heavy documents (contracts, reports): extract text and send as plain text to any backend.
  • Visually rich documents (presentations, forms): use a multimodal native PDF reader that processes multiple pages.
  • Quick summaries of the first page only: a first-page-only backend may suffice, but be explicit about the limitation.

Remember that the aggregator charges official price × 1.3 for usage, so inefficient PDF handling can increase costs. Sending the full PDF to a backend that only reads page one wastes tokens on unused pages.

Example: Sending a PDF via the API

Most aggregator APIs accept PDFs as base64-encoded data or via a file upload endpoint. The exact format depends on the backend. For text-only backends, you must preprocess the PDF into text.

Here is a conceptual workflow:

  1. Extract text from your PDF using a tool like pdfplumber or pypdf.
  2. Send the extracted text as part of the prompt to any model.
  3. For visual tasks, send the PDF to a backend that natively supports multi-page PDF input.

Always check the model's supported input types in the docs before sending.

Cost Considerations

When you send a PDF, you are billed for the input tokens. If you send a large PDF to a backend that only reads the first page, you may still be charged for the entire file's token count (depending on how the aggregator counts tokens). To avoid waste, preprocess PDFs to match the backend's capabilities.

Key contributors to this aggregator are credited official price × 1.1 (or × 1.2 for premium) in USDC, so efficient token usage benefits everyone.