Images and PDFs
Images and PDFs go directly in the message, alongside the text. Encode the file in base64 and put it in the request: the router has no separate file upload.
To check whether a model supports them, look in GET /v1/models:
- images:
capabilities.modality_inputincludesimage; - PDFs:
capabilities.featuresincludespdf_input.
See Models.
Images on Chat Completions
Section titled “Images on Chat Completions”The message content becomes an array of blocks. Pass the image in an image_url block with a data: URL:
B64=$(base64 < chart.png | tr -d '\n')
curl https://api.waibee.com/v1/chat/completions \ -H "Authorization: Bearer $WAIBEE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "google/gemini-3.6-flash", "messages": [{ "role": "user", "content": [ { "type": "text", "text": "What is in the image? One word." }, { "type": "image_url", "image_url": { "url": "data:image/png;base64,'"$B64"'" } } ] }] }'One message can hold several blocks: text and images go in the order you list them.
PDFs on Chat Completions
Section titled “PDFs on Chat Completions”Pass the document in a file block: the file name plus its content in file_data.
{ "role": "user", "content": [ { "type": "file", "file": { "filename": "report.pdf", "file_data": "data:application/pdf;base64,<base64>" } }, { "type": "text", "text": "Find the total amount in the document." } ]}Images and PDFs on Messages
Section titled “Images and PDFs on Messages”The Anthropic format uses image and document blocks with a source object:
{ "role": "user", "content": [ { "type": "document", "source": { "type": "base64", "media_type": "application/pdf", "data": "<base64>" } }, { "type": "text", "text": "What code is given in the document?" } ]}For an image, the block type is image, and media_type matches the format (image/png, image/jpeg, image/webp).
Images and PDFs on Responses
Section titled “Images and PDFs on Responses”On POST /v1/responses, pass an image in an input_image block with a data: URL in image_url, and a PDF in an input_file block with filename and file_data in the same form as on Chat Completions.
Limits
Section titled “Limits”The size of a single file and of the whole request body is limited; the values and error codes are in Limits. Going over returns 413.
The per-file limit applies to the original size, before encoding. The body limit applies to what goes over the network, and base64 makes a file about a third larger: two files that are each within the limit can together exceed the body size.
What to keep in mind
Section titled “What to keep in mind”- Attachments are billed as input tokens. Each model has its own conversion rules: a PDF page or a large image can cost several thousand tokens. Check the actual cost in
usage; see Tokens and usage. - Shrink images before sending. The model scales the image down to its resolution limit anyway, and the extra pixels turn into extra tokens and latency.
- Scans are read by the model, not by a separate OCR step. Quality drops noticeably on poor scans and handwriting: if this is your main use case, test the results on your own files.
- Split multi-page PDFs. Splitting a document and asking about a specific section is usually cheaper and more accurate than sending a hundred pages in one request.
- Cache a document you reuse. If you ask several questions about one file, mark the document block with
cache_control; see Prompt caching.