Sending files

Early access
Copy Page as Markdown

Upload a file once via the Files API and reference it by file_id on Chat Completions or Responses, or send it inline — base64-encoded directly in the request — on Chat Completions only.

Field reference

Responses APIChat Completions
Part typeinput_filefile
Inline base64Not supportedfile_data
Uploaded filefile_id (required)file_id

Inline base64

Inline file_data is Chat Completions only. Include a text part with your instruction, then one or more file parts for the documents.

cURLTypeScriptPython

Set file_data to the base64-encoded file content — plain, with no line wrapping. Do not use a data URL prefix such as data:application/pdf;base64,.

File part

FieldTypeRequiredDescription
typestringYesMust be "file".
filenamestringNoRecommended. File name to associate with the document, such as financial-report-2026.pdf or meeting-notes.txt.
mime_typestringYesMIME type for the file, such as "application/pdf" or "text/plain".
file_datastringYesBase64-encoded file content.

Accepted file types

Set mime_type to match the file you send.

CategoryExtensionsMIME type
PDF.pdfapplication/pdf
Plain text.txttext/plain
Markdown.mdtext/markdown
CSV.csvtext/csv
TSV.tsvtext/tab-separated-values
JSON.jsonapplication/json
XML.xmlapplication/xml or text/xml

Word (.doc/.docx) and JSONL aren't accepted inline — upload them and pass file_id instead. See Files API for the full uploaded-file format list.

Uploaded files

Upload the document once, then pass the id it returns as file_id. Reference more than one document by adding a part per file. Responses uses input_file parts; Chat Completions uses file parts.

cURLTypeScriptPython

Non-text formats need to finish processing first — wait for status to reach processed before referencing them. See Files API for upload mechanics, visibility, and the rest of the file lifecycle. Responses does not accept inline file_data; see Responses input.

Choosing an approach

Inline base64Uploaded file
Sent asfile_data on the requestfile_id from an earlier upload
Extra requestNonePOST /v1/files once per file
ReuseRe-sends the bytes every timeReference the same file_id repeatedly
Accepted formatsPDF, plain text, Markdown, CSV, TSV, JSON, and XMLAdds JSONL and Word (.doc/.docx)
SizeBounded by your request size50 MB per file
LifetimeRequest-scopedStored per organization until deleted

Inline base64 is the shortest path for a one-off Chat Completions request. Upload the file instead when you are calling Responses, when the same document is used across several requests, when it is large, or when it is a format inline input does not accept.

Response handling

Once a file's status is processed, its content is available to the model for that request — the reply is ordinary assistant text, the same as any other turn. Combine with Structured outputs to extract specific fields from the document instead of a free-text summary.