Send a PDF to an LLM API: request shape, limits, redaction

How to put a PDF, Word, Excel or HTML file into a chat request as a file part, which models read it natively, the size limits, and how secrets are masked.

Checked 2026-11-22

·All posts·Models

A PDF, document or image goes into a chat request as a file part and is read to text at the gateway before any model sees it, so a model with no file support still answers about the file; below is the request shape, the limits, and what the redaction setting does to the file on the way in. The three shapes, the formats and the limits in this post come from the OpenAPI document and the file_parsing object of the keyless GET https://api.uplinkswitch.com/v1/catalog.

Three request shapes, one behaviour

The catalog's file_input field describes a document part as one of three things: a chat file part on /v1/chat/completions, a document block on /v1/messages, or an input_file part on /v1/responses. Whichever one your SDK produces, the gateway treats it the same way. The file can be base64 data or an http(s) URL; the live feature page notes that private and internal URLs are refused.

What happens next depends on one field per model. A model whose file_input is native receives the file exactly as sent. A model whose file_input is parsed receives the text instead: the gateway converts the document first and hands the model the text with the file's name in front of it. Your code does not branch on this; you send the same part either way and read the answer.

The request, in Python and curl

The OpenAI SDK with its base URL pointed at the gateway. Only the model field decides whether the PDF arrives as a file or as text.

python
import base64
from openai import OpenAI

client = OpenAI(base_url="https://api.uplinkswitch.com/v1", api_key="sk-uplink-live-...")

with open("lease.pdf", "rb") as f:
    pdf_b64 = base64.b64encode(f.read()).decode()

answer = client.chat.completions.create(
    model="gpt-6.1-sol",
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "When does this lease end, and what is the notice period?"},
            {"type": "file", "file": {
                "filename": "lease.pdf",
                "file_data": f"data:application/pdf;base64,{pdf_b64}",
            }},
        ],
    }],
)
print(answer.choices[0].message.content)
print(answer.usage.cost)  # the charge for this request, in USD

The same file by URL, on the Responses route, to a model that has no native file input and so gets the parsed text:

bash
curl https://api.uplinkswitch.com/v1/responses \
  -H "Authorization: Bearer $UPLINK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v4.1-flash",
    "input": [{"role": "user", "content": [
      {"type": "input_text", "text": "Summarise the termination clauses."},
      {"type": "input_file", "file_url": "https://example.com/lease.pdf"}
    ]}]
  }'

In the response body, model says which model answered and usage.cost is what the request took from your balance; and the response headers carry a request id that finds the call later on the console's Usage page.

Which models read a PDF natively

The catalog marks each chat model native or parsed. A few of each, with the price you pay here beside the developer's list price:

ModelDeveloperfile_inputOur price, in / out per 1MList
gpt-6.1-solOpenAInative$0.582 / $2.91$2.00 / $10.00
claude-sonnet-5-5Anthropicnative$1.164 / $2.91$2.00 / $10.00
gemini-4-argonGooglenative$0.582 / $2.91$2.00 / $10.00
deepseek-v4.1-flashDeepSeekparsed$0.0564 / $0.1692$0.30 / $1.20
glm-5.3-flashZ.aiparsed$0.0873 / $0.1455$0.15 / $0.50
kimi-k3Moonshot AIparsed$0.90 / $4.50$3.00 / $15.00

The split is not about quality. A native reader sees the page layout, so it can answer about a chart or a scanned stamp; a parsed model sees the extracted text, which is what most contract, invoice and report questions need, and the cheaper ids on this catalog are mostly in the parsed group. Read the field on the model's row before you pick, since it changes as developers add file support.

The limits, from the catalog

The top-level file_parsing object of the catalog states what the parser accepts, read live when this page renders:

FieldValue
formatsbmp, csv, docx, et, gif, htm, html, jpeg, jpg, md, numbers, ods, odt, pdf, png, svg, txt, webp, xls, xlsb, xlsm, xlsx, xml
max_file_mb20
max_pages50
max_output_chars200,000
usd_per_page$0.00

A file over max_file_mb is refused rather than truncated. A document longer than max_pages or max_output_chars is cut at the limit, and the OpenAPI document says the cut comes with a note so the model and you both know the text is partial. Spreadsheets, Word and OpenDocument files and plain HTML are in the list, so the same request shape covers an exported ledger or a saved web page, not only PDFs.

Two consequences for cost. First, a parsed document becomes input tokens billed at the model's input rate, so a long contract on a frontier model costs what the same text would cost pasted in; the usd_per_page figure is the only charge the parsing itself adds. Second, the same document sent twice is the same input twice, unless the model has a cached-input price and your SDK keeps the prefix stable, or you turn on the response cache for an exact repeat (described on /features/caching).

What the redaction setting does to the file

A document often carries the very things you do not want a model to read: API keys in a config dump, card numbers on an invoice, an employee's email in a memo. The redaction setting runs before the request leaves the gateway, on the message text the model will receive, including text parsed out of a file.

It has three values. off sends the text as written. secrets replaces API keys, tokens and private keys with placeholders of the form [[SECRET_1]]. secrets_pii does that and also masks email addresses, phone and card numbers, US Social Security numbers and IBANs. When the model repeats a placeholder in its answer, the gateway swaps the original back in, in whole and in streamed answers, so the caller sees real values and the model never did. The response headers report how many values were replaced.

Set it once on the key, with the redact field on POST or PATCH /v1/keys (an admin key, created in the console) or in the key's dialog in the console:

bash
curl -X PATCH https://api.uplinkswitch.com/v1/keys/KEY_ID \
  -H "Authorization: Bearer $UPLINK_ADMIN_KEY" \
  -H "Content-Type: application/json" \
  -d '{"redact": "secrets_pii"}'

A single request can override the key's value; the per-request form is on /features/files-redaction. Two details from the OpenAPI document and that page matter for document work: the setting is inherited by every server-tool round, so a fetched page or search result that flows back to the model is redacted too, and a redacted request is never kept in the response cache, so a masked answer cannot be replayed to a later caller.

Files with a fallback list

If the request names a models fallback list rather than one model, the live feature page describes the rule: the file reaches the models untouched only if each id on the list is a native reader; if any of them is a parsed model, the gateway converts the file to text a single time and that text goes to whichever model ends up answering. Mixing a native reader with a parsed one in a fallback list therefore gives you the parsed behaviour for all of them, which is predictable and, for most text questions, fine.

Checklist before you ship

  1. Read file_parsing from the catalog in your build, not from this page; the formats and limits are live fields.
  2. Pick the model by file_input only if layout matters; otherwise pick by price and let the parser do the work.
  3. Put redact on the key that handles customer documents, and keep that key's monthly spend limit low.
  4. Send max_tokens, since a document question can invite a long answer and the balance hold assumes a large one when you do not.
  5. Read usage.cost on each response and compare it with the estimate from POST /v1/estimate, which prices the same messages on every model before you send.

Questions and answers

Every chat model on the catalog accepts a file part. Models whose file_input field is native (on the reading date gemini-4-argon, claude-sonnet-5-5 and gpt-6.1-sol were three of them) get the file as sent; every other model gets the document converted to text by the gateway, so the same request works on all of them.

The catalog's file_parsing object sets the limits for parsed documents: max_file_mb is 20, max_pages 50 and max_output_chars 200,000. A larger file is refused; a longer document is cut at the limit with a note. Native readers take the file as sent, within the developer's own limits.

Yes. The redaction setting on the key, secrets or secrets_pii, swaps API keys, tokens and private keys for placeholders before the request is forwarded; secrets_pii extends that to email addresses, phone and card numbers, US Social Security numbers and IBANs. The originals are restored in the answer, and the count of replacements is reported in the response headers.
Join on Telegram
Help