Skip to content

File inputs

Send PDFs and images inside a chat request as file parts. Which models read them, the size and count limits, and the errors to expect.

Markdown
On this page

A model that reads documents can answer questions about a PDF you send with the request: an invoice, a contract, a report. Lykia accepts the file in OpenAI's file-part format and converts it to each provider's own document format.

Send a file

Add a file part to a user message's content array, with the file as a base64 data: URI:

# Send a PDF from disk as a data: URI (base64 without line breaks).
FILE_DATA="data:application/pdf;base64,$(base64 < report.pdf | tr -d '\n')"

curl https://api.getlykia.com/v1/chat/completions \
  -H "Authorization: Bearer $LYKIA_API_KEY" \
  -H "Content-Type: application/json" \
  -d @- <<JSON
{
  "model": "anthropic/claude-sonnet-4.5",
  "messages": [
    {
      "role": "user",
      "content": [
        { "type": "text", "text": "List the totals in this report." },
        { "type": "file", "file": { "filename": "report.pdf", "file_data": "$FILE_DATA" } }
      ]
    }
  ]
}
JSON
typestring

file.

file.filenamestring

The file's name. Some providers show it to the model as the document's title.

file.file_datastring

The file as data:<media type>;base64,<data>, without line breaks.

What is accepted

  • Types: PDF (application/pdf) and images (image/png, image/jpeg, image/gif, image/webp). Images can also be sent as image_url parts, as before.
  • Count: at most eight files per request (400, too_many_files).
  • Size: the whole request body, files included, must fit Lykia's body size limit (413 beyond it). Large documents also count against the model's context window.
  • Models: the model must list file (for PDFs) or image (for images) in its input_modalities in GET /models. When the request has fallback models or several providers, candidates that cannot read the file are skipped.

A file of another type, or a request where no candidate can read the file, gets 400 with the code unsupported_input.

Provider familyHow the file is sent
AnthropicPDF as a document block (the file name becomes its title), images as image blocks
Google AI StudioInline data with the file's media type
OpenAI-compatibleThe file part as it is, for providers whose models read files

Cost and privacy

File content is billed as input tokens, counted by the provider; a PDF's pages usually cost more tokens than their text alone. Before sending, Lykia reserves the request's maximum cost, estimating the file's size in tokens from its bytes, so a large file needs enough available balance (see Reservations).

Files are passed to the provider with the request and not stored by Lykia. With prompt logging on, the request body, files included, is stored in the record up to the size cap; see Privacy and logging.

Next steps