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 each project can store up to 2.5 TB of files in total. There is no organization-wide storage limit.
- 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
.jsonlfiles. The input also has certain required formats for fine-tuning chat or completions models. - The Batch API only supports
.jsonlfiles 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. One of:
assistants: Used in the Assistants APIbatch: Used in the Batch APIfine-tune: Used for fine-tuningvision: Images used for vision fine-tuninguser_data: Flexible file type for any purposeevals: Used for eval data sets
Returns
The uploaded File object.
1
2
3
4
5
6
curl https://api.openai.com/v1/files \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-F purpose="fine-tune" \
-F file="@mydata.jsonl"
-F expires_after[anchor]="created_at"
-F expires_after[seconds]=25920001
2
3
4
5
6
7
8
9
{
"id": "file-abc123",
"object": "file",
"bytes": 120000,
"created_at": 1677610602,
"expires_at": 1677614202,
"filename": "mydata.jsonl",
"purpose": "fine-tune",
}List files
Returns a list of files.
Query parameters
A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
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
22
23
24
25
26
{
"object": "list",
"data": [
{
"id": "file-abc123",
"object": "file",
"bytes": 175,
"created_at": 1613677385,
"expires_at": 1677614202,
"filename": "salesOverview.pdf",
"purpose": "assistants",
},
{
"id": "file-abc456",
"object": "file",
"bytes": 140,
"created_at": 1613779121,
"expires_at": 1677614202,
"filename": "puppy.jsonl",
"purpose": "fine-tune",
}
],
"first_id": "file-abc123",
"last_id": "file-abc456",
"has_more": false
}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
9
{
"id": "file-abc123",
"object": "file",
"bytes": 120000,
"created_at": 1677610602,
"expires_at": 1677614202,
"filename": "mydata.jsonl",
"purpose": "fine-tune",
}Delete file
Delete a file and remove it from all vector stores.
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.jsonlThe 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, vision, and user_data.
Deprecated. The current status of the file, which can be either uploaded, processed, or error.
1
2
3
4
5
6
7
8
9
{
"id": "file-abc123",
"object": "file",
"bytes": 120000,
"created_at": 1677610602,
"expires_at": 1680202602,
"filename": "salesOverview.pdf",
"purpose": "assistants",
}