Files
Files are used to upload documents that can be used with features like Assistants, Fine-tuning, and Batch API.
Upload file
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
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.
1
2
3
4
curl https://api.openai.com/v1/files \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-F purpose="fine-tune" \
-F file="@mydata.jsonl"
1
2
3
4
5
6
7
8
{
"id": "file-abc123",
"object": "file",
"bytes": 120000,
"created_at": 1677610602,
"filename": "mydata.jsonl",
"purpose": "fine-tune",
}
List files
Returns a list of files.
Query parameters
A limit on the number of objects to be returned. Limit can range between 1 and 10,000, and the default is 10,000.
Sort order by the created_at
timestamp of the objects. asc
for ascending order and desc
for descending order.
Returns
A list of File objects.
1
2
curl https://api.openai.com/v1/files \
-H "Authorization: Bearer $OPENAI_API_KEY"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{
"data": [
{
"id": "file-abc123",
"object": "file",
"bytes": 175,
"created_at": 1613677385,
"filename": "salesOverview.pdf",
"purpose": "assistants",
},
{
"id": "file-abc123",
"object": "file",
"bytes": 140,
"created_at": 1613779121,
"filename": "puppy.jsonl",
"purpose": "fine-tune",
}
],
"object": "list"
}
Retrieve file
Returns information about a specific file.
Returns
The File object matching the specified ID.
1
2
curl https://api.openai.com/v1/files/file-abc123 \
-H "Authorization: Bearer $OPENAI_API_KEY"
1
2
3
4
5
6
7
8
{
"id": "file-abc123",
"object": "file",
"bytes": 120000,
"created_at": 1677610602,
"filename": "mydata.jsonl",
"purpose": "fine-tune",
}
Delete file
Delete a file.
Returns
Deletion status.
1
2
3
curl https://api.openai.com/v1/files/file-abc123 \
-X DELETE \
-H "Authorization: Bearer $OPENAI_API_KEY"
1
2
3
4
5
{
"id": "file-abc123",
"object": "file",
"deleted": true
}
Retrieve file content
Returns the contents of the specified file.
Returns
The file content.
1
2
curl https://api.openai.com/v1/files/file-abc123/content \
-H "Authorization: Bearer $OPENAI_API_KEY" > file.jsonl
The file object
The File
object represents a document that has been uploaded to OpenAI.
The intended purpose of the file. Supported values are assistants
, assistants_output
, batch
, batch_output
, fine-tune
, fine-tune-results
and vision
.
Deprecated. The current status of the file, which can be either uploaded
, processed
, or error
.
1
2
3
4
5
6
7
8
{
"id": "file-abc123",
"object": "file",
"bytes": 120000,
"created_at": 1677610602,
"filename": "salesOverview.pdf",
"purpose": "assistants",
}