Document input
Send a PDF to a chat model as a content part. The model reads the document and answers in text. The exchange does not parse the PDF. Only an offer that declared file input can win the job.
{
"role": "user",
"content": [
{ "type": "text", "text": "summarise the risks in this report" },
{
"type": "file",
"file": { "filename": "q3.pdf", "file_data": "data:application/pdf;base64,JVBER…" }
}
]
}
Examples
Summarise a report. Send the PDF with a short instruction.
{
"role": "user",
"content": [
{ "type": "text", "text": "Summarise the risks in this report. Cite page numbers." },
{
"type": "file",
"file": { "filename": "q3.pdf", "file_data": "data:application/pdf;base64,JVBER…" }
}
]
}
Extract fields from an invoice. Ask for JSON, so a program can read the answer.
{
"role": "user",
"content": [
{ "type": "text", "text": "Return the invoice number, date and total as JSON." },
{
"type": "file",
"file": { "filename": "invoice-1042.pdf", "file_data": "data:application/pdf;base64,JVBER…" }
}
]
}
A long PDF costs 3,000 tokens for each page in the cap. Send only the pages that you need.
Send a PDF
| API | Part |
|---|---|
| Chat Completions | file with filename and file_data |
| Responses | input_file with file_data |
| Messages | document block with a base64 source |
file_data is a data:application/pdf;base64,… URL. The exchange refuses a document URL or a file_id, because it cannot count pages without the bytes.
The exchange sends filename to the provider. Some upstreams show it to the model.
Cost
The exchange counts the pages of the PDF from its structure. It converts each page to 3,000 input tokens, unless the offer states its own table. The charge is the token count that the provider meters.
Models that cannot read files
A request with a PDF reaches only offers that read files. This applies to a named model and to liquid.auto. Auto refuses the request with 400 unsupported_parameter when no offer reads files.
The exchange does not extract text from the PDF for a model that cannot read files. To use a text-only model, extract the text yourself and send it as a text part.
Troubleshooting
| Error | Cause | Fix |
|---|---|---|
400 unsupported_parameter |
No offer for the model reads files. | Pick a model with file in input_modalities. |
400 unsupported_content |
A URL, a file_id, or a broken PDF. |
Send the PDF bytes as base64. |
413 request_too_large |
The body is over 20 MB. | Split the document. |
Next steps
- Modalities: the map of all modalities.
- Image input: send an image.