POST
/filesUpload a file
Creates a file that you can use across supported API endpoints. Send the file as multipart form data with a supported purpose, and optionally provide an expires_after policy. Files can be up to 512 MB, while batch JSONL files have a separate 200 MB limit.
- RetriesRetries up to 2×, 500ms backoff, 30s timeout.
Multipart form data containing the file, its intended purpose, and an optional expiration policy.
filestringrequired
The File object (not file name) to be uploaded.
purposestringrequired
The intended purpose of the uploaded file. One of:
- `assistants`: Used in the Assistants API
- `batch`: Used in the Batch API
- `fine-tune`: Used for fine-tuning
- `vision`: Images used for vision fine-tuning
- `user_data`: Flexible file type for any purpose
- `evals`: Used for eval data sets
expires_afterobjectoptional
The expiration policy for a file. By default, files with `purpose=batch` expire after 30 days and all other files are persisted until they are manually deleted.
200Returns the created file object, including its identifier, size, creation time, filename, purpose, and status.
idstringrequired
The file identifier, which can be referenced in the API endpoints.
bytesintegerrequired
The size of the file, in bytes.
created_atintegerrequired
The Unix timestamp (in seconds) for when the file was created.
expires_atintegeroptional
The Unix timestamp (in seconds) for when the file will expire.
filenamestringrequired
The name of the file.
objectstringrequired
The object type, which is always `file`.
purposestringrequired
The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`, `vision`, and `user_data`.
statusstringdeprecatedrequired
Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.
status_detailsstringdeprecatedoptional
Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`.
Error handling
file and purpose are required. purpose must be one of assistants, batch, fine-tune, vision, user_data, or evals; when supplied, expires_after.anchor must be created_at and expires_after.seconds must be between 3,600 and 2,592,000.