POST/uploads

Create an upload

Creates an upload that accepts file parts before they are assembled into a usable file. Provide the filename, purpose, byte count, and MIME type; uploads can contain up to 8 GB and expire after one hour. Add parts to the upload, then complete it to create the file.

  • IdempotentThe SDK sends Idempotency-Key, so a retried request is only applied once.

5 body fields

Details for creating an upload. filename, purpose, bytes, and mime_type are required.

filenamestringrequired
The name of the file to upload.
purposestringrequired
The intended purpose of the uploaded file. See the [documentation on File purposes](https://developers.openai.com/api/reference/resources/files/methods/create#%28resource%29%20files%20%3E%20%28method%29%20create%20%3E%20%28params%29%200%20%3E%20%28param%29%20purpose%20%3E%20%28schema%29).
Allowed:assistantsbatchfine-tunevision
bytesintegerrequired
The number of bytes in the file you are uploading.
mime_typestringrequired
The MIME type of the file. This must fall within the supported MIME types for your file purpose. See the supported MIME types for assistants and vision.
expires_afterobjectoptional
The expiration policy for a file. By default, files with `purpose=batch` expire after 30 days and all other files are persisted until they are manually deleted.

3 status codes
200Returns the created upload object with its ID, filename, intended byte count, purpose, pending status, and expiration time.
idstringrequired
The Upload unique identifier, which can be referenced in API endpoints.
created_atintegerrequired
The Unix timestamp (in seconds) for when the Upload was created.
filenamestringrequired
The name of the file to be uploaded.
bytesintegerrequired
The intended number of bytes to be uploaded.
purposestringrequired
The intended purpose of the file. [Please refer here](https://developers.openai.com/api/reference/resources/files#%28resource%29%20files%20%3E%20%28model%29%20file_object%20%3E%20%28schema%29%20%3E%20%28property%29%20purpose) for acceptable values.
statusstringrequired
The status of the Upload.
Allowed:pendingcompletedcancelledexpired
expires_atintegerrequired
The Unix timestamp (in seconds) for when the Upload will expire.
objectstringoptional
The object type, which is always "upload".
Allowed:upload
fileobjectoptional
The ready File object after the Upload is completed.
400Returned when the upload request is invalid or exceeds a file-size or storage-quota limit.
errorobjectrequired
429Returned when upload requests are sent too frequently.
errorobjectrequired

Error handling

A 400 is returned when the upload request is invalid or exceeds a file-size or storage-quota limit. A 429 is returned when upload requests are sent too frequently. filename, purpose, bytes, and mime_type are required; purpose must be assistants, batch, fine-tune, or vision, and the MIME type must be supported for that purpose.