Skip to main content
An OpenAI-compatible Files API for managing batch and fine-tune related files. All endpoints are relative to:
Fine-tuning is not yet supported.
Currently the only API that uses files is the Batch API, which accepts files of up to 200 MB.

Objects

The FileObject

Most file endpoints return a FileObject describing an uploaded file.

Create file

Creates a file used in other API endpoints. Creating a file requires the following parameters:
The file to be uploaded.
The intended purpose of the file. Can be "batch" or "fine-tune" for upload, but only "batch" is currently supported.
Controls how long the file remains available. An object with two fields:
  • anchor (optional) — must be "created_at". The expiry is measured from when the file is created. Defaults to "created_at".
  • seconds (optional) — the number of seconds the file stays available after the anchor. An integer between 3600 (1 hour) and 2592000 (30 days). Defaults to 2592000 (30 days).
This endpoint returns a FileObject.

List files

Listing files requires the following parameters:
A pagination cursor. The returned list starts from the object right after the file with this id. If omitted, the list starts from the first file.
An integer between 1 and 10000. The returned list will have at most limit elements. Defaults to 10000.
Sort order by created_at, either "asc" (ascending) or "desc" (descending).
Only returns files of the given purpose. If omitted, files are not filtered by purpose.
The returned object has the following fields:

Retrieve a file

Returns information about a specific file. Retrieving a file requires the following parameters:
The id of the file to retrieve.
This endpoint returns a FileObject.

Retrieve file content

Returns the content of a specified file. Retrieving file content requires the following parameters:
The id of the file whose content to retrieve.
This endpoint returns the binary response content.

Delete a file

Deletes a file and removes it from all storages. Deleting a file requires the following parameters:
The id of the file to delete.
This endpoint returns a FileDeleted object with the following fields:

File API Limits