Repository Public
1> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.23## Create upload45**post** `/uploads`67Creates an intermediate [Upload](/api/reference/resources/uploads) object8that you can add [Parts](/api/reference/resources/uploads/subresources/parts) to.9Currently, an Upload can accept at most 8 GB in total and expires after an10hour after you create it.1112Once you complete the Upload, we will create a13[File](/api/reference/resources/files) object that contains all the parts14you uploaded. This File is usable in the rest of our platform as a regular15File object.1617For certain `purpose` values, the correct `mime_type` must be specified.18Please refer to documentation for the19[supported MIME types for your use case](/api/docs/guides/tools-file-search#supported-files).2021For guidance on the proper filename extensions for each purpose, please22follow the documentation on [creating a23File](/api/reference/resources/files/methods/create).2425Returns the Upload object with status `pending`.2627### Body Parameters2829- `bytes: number`3031 The number of bytes in the file you are uploading.3233- `filename: string`3435 The name of the file to upload.3637- `mime_type: string`3839 The MIME type of the file.4041 This must fall within the supported MIME types for your file purpose. See42 the supported MIME types for assistants and vision.4344- `purpose: "assistants" or "batch" or "fine-tune" or "vision"`4546 The intended purpose of the uploaded file.4748 See the [documentation on File49 purposes](/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).5051 - `"assistants"`5253 - `"batch"`5455 - `"fine-tune"`5657 - `"vision"`5859- `expires_after: optional object { anchor, seconds }`6061 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.6263 - `anchor: "created_at"`6465 Anchor timestamp after which the expiration policy applies. Supported anchors: `created_at`.6667 - `"created_at"`6869 - `seconds: number`7071 The number of seconds after the anchor time that the file will expire. Must be between 3600 (1 hour) and 2592000 (30 days).7273### Returns7475- `Upload object { id, bytes, created_at, 6 more }`7677 The Upload object can accept byte chunks in the form of Parts.7879 - `id: string`8081 The Upload unique identifier, which can be referenced in API endpoints.8283 - `bytes: number`8485 The intended number of bytes to be uploaded.8687 - `created_at: number`8889 The Unix timestamp (in seconds) for when the Upload was created.9091 - `expires_at: number`9293 The Unix timestamp (in seconds) for when the Upload will expire.9495 - `filename: string`9697 The name of the file to be uploaded.9899 - `purpose: string`100101 The intended purpose of the file. [Please refer here](/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.102103 - `status: "pending" or "completed" or "cancelled" or "expired"`104105 The status of the Upload.106107 - `"pending"`108109 - `"completed"`110111 - `"cancelled"`112113 - `"expired"`114115 - `file: optional FileObject or null`116117 The `File` object represents a document that has been uploaded to OpenAI.118119 - `id: string`120121 The file identifier, which can be referenced in the API endpoints.122123 - `bytes: number`124125 The size of the file, in bytes.126127 - `created_at: number`128129 The Unix timestamp (in seconds) for when the file was created.130131 - `filename: string`132133 The name of the file.134135 - `object: "file"`136137 The object type, which is always `file`.138139 - `"file"`140141 - `purpose: "assistants" or "assistants_output" or "batch" or 5 more`142143 The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`, `vision`, and `user_data`.144145 - `"assistants"`146147 - `"assistants_output"`148149 - `"batch"`150151 - `"batch_output"`152153 - `"fine-tune"`154155 - `"fine-tune-results"`156157 - `"vision"`158159 - `"user_data"`160161 - `status: "uploaded" or "processed" or "error"`162163 Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.164165 - `"uploaded"`166167 - `"processed"`168169 - `"error"`170171 - `expires_at: optional number`172173 The Unix timestamp (in seconds) for when the file will expire.174175 - `status_details: optional string`176177 Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`.178179 - `object: optional "upload"`180181 The object type, which is always "upload".182183 - `"upload"`184185### Example186187```http188curl https://api.openai.com/v1/uploads \189 -H 'Content-Type: application/json' \190 -H "Authorization: Bearer $OPENAI_API_KEY" \191 -d '{192 "bytes": 0,193 "filename": "filename",194 "mime_type": "mime_type",195 "purpose": "assistants"196 }'197```198199#### Response200201```json202{203 "id": "id",204 "bytes": 0,205 "created_at": 0,206 "expires_at": 0,207 "filename": "filename",208 "purpose": "purpose",209 "status": "pending",210 "file": {211 "id": "id",212 "bytes": 0,213 "created_at": 0,214 "filename": "filename",215 "object": "file",216 "purpose": "assistants",217 "status": "uploaded",218 "expires_at": 0,219 "status_details": "status_details"220 },221 "object": "upload"222}223```224225### Example226227```http228curl https://api.openai.com/v1/uploads \229 -H "Authorization: Bearer $OPENAI_API_KEY" \230 -d '{231 "purpose": "fine-tune",232 "filename": "training_examples.jsonl",233 "bytes": 2147483648,234 "mime_type": "text/jsonl",235 "expires_after": {236 "anchor": "created_at",237 "seconds": 3600238 }239 }'240```241242#### Response243244```json245{246 "id": "upload_abc123",247 "object": "upload",248 "bytes": 2147483648,249 "created_at": 1719184911,250 "filename": "training_examples.jsonl",251 "purpose": "fine-tune",252 "status": "pending",253 "expires_at": 1719127296254}255```256