Sending files
Early accessUpload 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 API | Chat Completions | |
|---|---|---|
| Part type | input_file | file |
| Inline base64 | Not supported | file_data |
| Uploaded file | file_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.
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
| Field | Type | Required | Description |
|---|---|---|---|
type | string | Yes | Must be "file". |
filename | string | No | Recommended. File name to associate with the document, such as financial-report-2026.pdf or meeting-notes.txt. |
mime_type | string | Yes | MIME type for the file, such as "application/pdf" or "text/plain". |
file_data | string | Yes | Base64-encoded file content. |
Accepted file types
Set mime_type to match the file you send.
| Category | Extensions | MIME type |
|---|---|---|
.pdf | application/pdf | |
| Plain text | .txt | text/plain |
| Markdown | .md | text/markdown |
| CSV | .csv | text/csv |
| TSV | .tsv | text/tab-separated-values |
| JSON | .json | application/json |
| XML | .xml | application/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.
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 base64 | Uploaded file | |
|---|---|---|
| Sent as | file_data on the request | file_id from an earlier upload |
| Extra request | None | POST /v1/files once per file |
| Reuse | Re-sends the bytes every time | Reference the same file_id repeatedly |
| Accepted formats | PDF, plain text, Markdown, CSV, TSV, JSON, and XML | Adds JSONL and Word (.doc/.docx) |
| Size | Bounded by your request size | 50 MB per file |
| Lifetime | Request-scoped | Stored 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.
Related
- Files API — upload, list, retrieve, and delete stored files.
- Chat Completions API —
fileparts onmessages. - Responses API —
input_fileparts oninput. - Models — supported model IDs.