Upload file
POST https://api.fastapi.ai/v1/files
Upload a file that can be used across various endpoints. Individual files can be up to 512 MB, and the size of all files uploaded by one organization can be up to 100 GB.
The Assistants API supports files up to 2 million tokens and of specific file types. See the Assistants Tools guide for details.
The Fine-tuning API only supports .jsonl
files. The input also has certain required formats for fine-tuning chat or completions models.
The Batch API only supports .jsonl
files up to 200 MB in size. The input also has a specific required format.
Please contact us if you need to increase these storage limits.
Request body
file
file Required
The File object (not file name) to be uploaded.
purpose
string Required
The intended purpose of the uploaded file.
Use "assistants" for Assistants and Message files, "vision" for Assistants image file inputs, "batch" for Batch API, and "fine-tune" for Fine-tuning.
Returns
The uploaded File object.
The file object
The File object represents a document that has been uploaded to OpenAI.
id
string
The file identifier, which can be referenced in the API endpoints.
bytes
integer
The size of the file, in bytes.
created_at
integer
The Unix timestamp (in seconds) for when the file was created.
expires_at
integer
The Unix timestamp (in seconds) for when the file will expire.
filename
string
The name of the file.
object
string
The object type, which is always file
.
purpose
string
The intended purpose of the file. Supported values are assistants
, assistants_output
, batch
, batch_output
, fine-tune
, fine-tune-results
and vision
.
status
Deprecated string
Deprecated. The current status of the file, which can be either uploaded
, processed
, or error
.
status_details
Deprecated string
Deprecated. For details on why a fine-tuning training file failed validation, see the error field on fine_tuning.job
.
{
"id": "file-abc123",
"object": "file",
"bytes": 120000,
"created_at": 1677610602,
"expires_at": 1680202602,
"filename": "salesOverview.pdf",
"purpose": "assistants",
}
Example
Request
curl https://api.fastapi.ai/v1/files \
-H "Authorization: Bearer $FAST_API_KEY" \
-F purpose="fine-tune" \
-F file="@mydata.jsonl"
Response
{
"id": "file-abc123",
"object": "file",
"bytes": 120000,
"created_at": 1677610602,
"filename": "mydata.jsonl",
"purpose": "fine-tune",
}