Upload file

post https://api.openai.com/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.source

The Assistants API supports files up to 2 million tokens and of specific file types. See the Assistants Tools guide for details.source

The Fine-tuning API only supports .jsonl files. The input also has certain required formats for fine-tuning chat or completions models.source

The Batch API only supports .jsonl files up to 200 MB in size. The input also has a specific required format.source

Please contact us if you need to increase these storage limits.source

Request body

The File object (not file name) to be uploaded.source

The intended purpose of the uploaded file.source

Use "assistants" for Assistants and Message files, "vision" for Assistants image file inputs, "batch" for Batch API, and "fine-tune" for Fine-tuning.source

Returns

The uploaded File object.source

Example request
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"
Response
1
2
3
4
5
6
7
8
{
  "id": "file-abc123",
  "object": "file",
  "bytes": 120000,
  "created_at": 1677610602,
  "filename": "mydata.jsonl",
  "purpose": "fine-tune",
}