Skip to Content

Sending files

Preview
Copy Page as Markdown

Send a small, one-off file inline with Chat Completions. Upload first when you use Responses, reuse a file, or need the larger upload limit.

Choose a method

Inline base64Uploaded file
Available onChat CompletionsChat Completions and Responses
Request fieldfile_datafile_id returned by POST /v1/files
Best forOne-off filesReuse, Responses, and larger files
Size25 MiB for the whole request, base64 included (about 18 MiB of file bytes)50 MiB per file; 10 MiB per image
RetentionFollows the request policy; inline PDF and Word persistKept until you delete the file

See Data retention for storage details.

Format support

FormatInline ChatUploaded ChatUploaded Responses
PDF, Word, text, Markdown, CSV, TSV, JSON, XMLYesYesYes
PNG, JPEG, WebPYesYesYes, as input_image
JSONLNoYesYes
  • Responses images: send an uploaded image as { "type": "input_image", "file_id": "file_img456" }. See Uploaded images.
  • Word: keep a .doc or .docx filename so SubQ can detect the format.
  • Uploaded non-text files: wait for status: "processed" before using the ID.

Inline base64

Inline file_data is Chat Completions only. Pass raw base64 with no line wrapping or data: prefix.

cURLTypeScriptPython

Use the flat file part shown above for every supported inline format:

{ "type": "file", "filename": "report.pdf", "file_data": "<base64>" }

For OpenAI compatibility, PDFs also accept a nested file object. Nested file parts are PDF-only and accept raw base64 or a data:application/pdf;base64, URI.

{ "type": "file", "file": { "filename": "report.pdf", "file_data": "<base64>" } }
FieldRequiredDescription
filenameRecommendedRequired for Word; use a .doc or .docx extension.
mime_typeNoIf omitted, SubQ detects the type from the bytes and filename.
file_dataYesBase64-encoded file bytes.

Use exactly one source per file part: file_data or file_id.

Uploaded files

Upload through the Files API with purpose assistants, then use the returned ID. The example IDs below represent values returned by POST /v1/files.

cURLTypeScriptPython

Chat Completions accepts the flat file_id part shown in the Chat tab for every supported format. PDFs also accept the nested OpenAI shape: { "type": "file", "file": { "file_id": "file_abc123" } }. Responses uses { "type": "input_file", "file_id": "file_abc123" } for documents and { "type": "input_image", "file_id": "file_img456" } for images.

Common errors

ErrorCause
400 validation_errorMalformed part, more than one source, invalid declared MIME type, or a Responses input_image with image_url instead of file_id
400 unsupported_file_typeUnsupported bytes, an image in a Responses input_file part, or a document in an input_image part
409 file_not_readyUploaded file has not reached processed
413File or inline request exceeds its size limit

See the Files API for upload mechanics and Structured outputs to extract fields instead of a free-text summary.

On this page