Repository Public
1# Uploads23> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.45## Cancel upload67**post** `/uploads/{upload_id}/cancel`89Cancels the Upload. No Parts may be added after an Upload is cancelled.1011Returns the Upload object with status `cancelled`.1213### Path Parameters1415- `upload_id: string`1617### Returns1819- `Upload object { id, bytes, created_at, 6 more }`2021 The Upload object can accept byte chunks in the form of Parts.2223 - `id: string`2425 The Upload unique identifier, which can be referenced in API endpoints.2627 - `bytes: number`2829 The intended number of bytes to be uploaded.3031 - `created_at: number`3233 The Unix timestamp (in seconds) for when the Upload was created.3435 - `expires_at: number`3637 The Unix timestamp (in seconds) for when the Upload will expire.3839 - `filename: string`4041 The name of the file to be uploaded.4243 - `purpose: string`4445 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.4647 - `status: "pending" or "completed" or "cancelled" or "expired"`4849 The status of the Upload.5051 - `"pending"`5253 - `"completed"`5455 - `"cancelled"`5657 - `"expired"`5859 - `file: optional FileObject or null`6061 The `File` object represents a document that has been uploaded to OpenAI.6263 - `id: string`6465 The file identifier, which can be referenced in the API endpoints.6667 - `bytes: number`6869 The size of the file, in bytes.7071 - `created_at: number`7273 The Unix timestamp (in seconds) for when the file was created.7475 - `filename: string`7677 The name of the file.7879 - `object: "file"`8081 The object type, which is always `file`.8283 - `"file"`8485 - `purpose: "assistants" or "assistants_output" or "batch" or 5 more`8687 The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`, `vision`, and `user_data`.8889 - `"assistants"`9091 - `"assistants_output"`9293 - `"batch"`9495 - `"batch_output"`9697 - `"fine-tune"`9899 - `"fine-tune-results"`100101 - `"vision"`102103 - `"user_data"`104105 - `status: "uploaded" or "processed" or "error"`106107 Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.108109 - `"uploaded"`110111 - `"processed"`112113 - `"error"`114115 - `expires_at: optional number`116117 The Unix timestamp (in seconds) for when the file will expire.118119 - `status_details: optional string`120121 Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`.122123 - `object: optional "upload"`124125 The object type, which is always "upload".126127 - `"upload"`128129### Example130131```http132curl https://api.openai.com/v1/uploads/$UPLOAD_ID/cancel \133 -X POST \134 -H "Authorization: Bearer $OPENAI_API_KEY"135```136137#### Response138139```json140{141 "id": "id",142 "bytes": 0,143 "created_at": 0,144 "expires_at": 0,145 "filename": "filename",146 "purpose": "purpose",147 "status": "pending",148 "file": {149 "id": "id",150 "bytes": 0,151 "created_at": 0,152 "filename": "filename",153 "object": "file",154 "purpose": "assistants",155 "status": "uploaded",156 "expires_at": 0,157 "status_details": "status_details"158 },159 "object": "upload"160}161```162163### Example164165```http166curl https://api.openai.com/v1/uploads/upload_abc123/cancel167```168169#### Response170171```json172{173 "id": "upload_abc123",174 "object": "upload",175 "bytes": 2147483648,176 "created_at": 1719184911,177 "filename": "training_examples.jsonl",178 "purpose": "fine-tune",179 "status": "cancelled",180 "expires_at": 1719127296181}182```183184## Complete upload185186**post** `/uploads/{upload_id}/complete`187188Completes the [Upload](/api/reference/resources/uploads).189190Within the returned Upload object, there is a nested [File](/api/reference/resources/files) object that is ready to use in the rest of the platform.191192You can specify the order of the Parts by passing in an ordered list of the Part IDs.193194The number of bytes uploaded upon completion must match the number of bytes initially specified when creating the Upload object. No Parts may be added after an Upload is completed.195Returns the Upload object with status `completed`, including an additional `file` property containing the created usable File object.196197### Path Parameters198199- `upload_id: string`200201### Body Parameters202203- `part_ids: array of string`204205 The ordered list of Part IDs.206207- `md5: optional string`208209 The optional md5 checksum for the file contents to verify if the bytes uploaded matches what you expect.210211### Returns212213- `Upload object { id, bytes, created_at, 6 more }`214215 The Upload object can accept byte chunks in the form of Parts.216217 - `id: string`218219 The Upload unique identifier, which can be referenced in API endpoints.220221 - `bytes: number`222223 The intended number of bytes to be uploaded.224225 - `created_at: number`226227 The Unix timestamp (in seconds) for when the Upload was created.228229 - `expires_at: number`230231 The Unix timestamp (in seconds) for when the Upload will expire.232233 - `filename: string`234235 The name of the file to be uploaded.236237 - `purpose: string`238239 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.240241 - `status: "pending" or "completed" or "cancelled" or "expired"`242243 The status of the Upload.244245 - `"pending"`246247 - `"completed"`248249 - `"cancelled"`250251 - `"expired"`252253 - `file: optional FileObject or null`254255 The `File` object represents a document that has been uploaded to OpenAI.256257 - `id: string`258259 The file identifier, which can be referenced in the API endpoints.260261 - `bytes: number`262263 The size of the file, in bytes.264265 - `created_at: number`266267 The Unix timestamp (in seconds) for when the file was created.268269 - `filename: string`270271 The name of the file.272273 - `object: "file"`274275 The object type, which is always `file`.276277 - `"file"`278279 - `purpose: "assistants" or "assistants_output" or "batch" or 5 more`280281 The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`, `vision`, and `user_data`.282283 - `"assistants"`284285 - `"assistants_output"`286287 - `"batch"`288289 - `"batch_output"`290291 - `"fine-tune"`292293 - `"fine-tune-results"`294295 - `"vision"`296297 - `"user_data"`298299 - `status: "uploaded" or "processed" or "error"`300301 Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.302303 - `"uploaded"`304305 - `"processed"`306307 - `"error"`308309 - `expires_at: optional number`310311 The Unix timestamp (in seconds) for when the file will expire.312313 - `status_details: optional string`314315 Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`.316317 - `object: optional "upload"`318319 The object type, which is always "upload".320321 - `"upload"`322323### Example324325```http326curl https://api.openai.com/v1/uploads/$UPLOAD_ID/complete \327 -H 'Content-Type: application/json' \328 -H "Authorization: Bearer $OPENAI_API_KEY" \329 -d '{330 "part_ids": [331 "string"332 ]333 }'334```335336#### Response337338```json339{340 "id": "id",341 "bytes": 0,342 "created_at": 0,343 "expires_at": 0,344 "filename": "filename",345 "purpose": "purpose",346 "status": "pending",347 "file": {348 "id": "id",349 "bytes": 0,350 "created_at": 0,351 "filename": "filename",352 "object": "file",353 "purpose": "assistants",354 "status": "uploaded",355 "expires_at": 0,356 "status_details": "status_details"357 },358 "object": "upload"359}360```361362### Example363364```http365curl https://api.openai.com/v1/uploads/upload_abc123/complete366 -d '{367 "part_ids": ["part_def456", "part_ghi789"]368 }'369```370371#### Response372373```json374{375 "id": "upload_abc123",376 "object": "upload",377 "bytes": 2147483648,378 "created_at": 1719184911,379 "filename": "training_examples.jsonl",380 "purpose": "fine-tune",381 "status": "completed",382 "expires_at": 1719127296,383 "file": {384 "id": "file-xyz321",385 "object": "file",386 "bytes": 2147483648,387 "created_at": 1719186911,388 "expires_at": 1719127296,389 "filename": "training_examples.jsonl",390 "purpose": "fine-tune",391 }392}393```394395## Create upload396397**post** `/uploads`398399Creates an intermediate [Upload](/api/reference/resources/uploads) object400that you can add [Parts](/api/reference/resources/uploads/subresources/parts) to.401Currently, an Upload can accept at most 8 GB in total and expires after an402hour after you create it.403404Once you complete the Upload, we will create a405[File](/api/reference/resources/files) object that contains all the parts406you uploaded. This File is usable in the rest of our platform as a regular407File object.408409For certain `purpose` values, the correct `mime_type` must be specified.410Please refer to documentation for the411[supported MIME types for your use case](/api/docs/guides/tools-file-search#supported-files).412413For guidance on the proper filename extensions for each purpose, please414follow the documentation on [creating a415File](/api/reference/resources/files/methods/create).416417Returns the Upload object with status `pending`.418419### Body Parameters420421- `bytes: number`422423 The number of bytes in the file you are uploading.424425- `filename: string`426427 The name of the file to upload.428429- `mime_type: string`430431 The MIME type of the file.432433 This must fall within the supported MIME types for your file purpose. See434 the supported MIME types for assistants and vision.435436- `purpose: "assistants" or "batch" or "fine-tune" or "vision"`437438 The intended purpose of the uploaded file.439440 See the [documentation on File441 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).442443 - `"assistants"`444445 - `"batch"`446447 - `"fine-tune"`448449 - `"vision"`450451- `expires_after: optional object { anchor, seconds }`452453 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.454455 - `anchor: "created_at"`456457 Anchor timestamp after which the expiration policy applies. Supported anchors: `created_at`.458459 - `"created_at"`460461 - `seconds: number`462463 The number of seconds after the anchor time that the file will expire. Must be between 3600 (1 hour) and 2592000 (30 days).464465### Returns466467- `Upload object { id, bytes, created_at, 6 more }`468469 The Upload object can accept byte chunks in the form of Parts.470471 - `id: string`472473 The Upload unique identifier, which can be referenced in API endpoints.474475 - `bytes: number`476477 The intended number of bytes to be uploaded.478479 - `created_at: number`480481 The Unix timestamp (in seconds) for when the Upload was created.482483 - `expires_at: number`484485 The Unix timestamp (in seconds) for when the Upload will expire.486487 - `filename: string`488489 The name of the file to be uploaded.490491 - `purpose: string`492493 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.494495 - `status: "pending" or "completed" or "cancelled" or "expired"`496497 The status of the Upload.498499 - `"pending"`500501 - `"completed"`502503 - `"cancelled"`504505 - `"expired"`506507 - `file: optional FileObject or null`508509 The `File` object represents a document that has been uploaded to OpenAI.510511 - `id: string`512513 The file identifier, which can be referenced in the API endpoints.514515 - `bytes: number`516517 The size of the file, in bytes.518519 - `created_at: number`520521 The Unix timestamp (in seconds) for when the file was created.522523 - `filename: string`524525 The name of the file.526527 - `object: "file"`528529 The object type, which is always `file`.530531 - `"file"`532533 - `purpose: "assistants" or "assistants_output" or "batch" or 5 more`534535 The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`, `vision`, and `user_data`.536537 - `"assistants"`538539 - `"assistants_output"`540541 - `"batch"`542543 - `"batch_output"`544545 - `"fine-tune"`546547 - `"fine-tune-results"`548549 - `"vision"`550551 - `"user_data"`552553 - `status: "uploaded" or "processed" or "error"`554555 Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.556557 - `"uploaded"`558559 - `"processed"`560561 - `"error"`562563 - `expires_at: optional number`564565 The Unix timestamp (in seconds) for when the file will expire.566567 - `status_details: optional string`568569 Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`.570571 - `object: optional "upload"`572573 The object type, which is always "upload".574575 - `"upload"`576577### Example578579```http580curl https://api.openai.com/v1/uploads \581 -H 'Content-Type: application/json' \582 -H "Authorization: Bearer $OPENAI_API_KEY" \583 -d '{584 "bytes": 0,585 "filename": "filename",586 "mime_type": "mime_type",587 "purpose": "assistants"588 }'589```590591#### Response592593```json594{595 "id": "id",596 "bytes": 0,597 "created_at": 0,598 "expires_at": 0,599 "filename": "filename",600 "purpose": "purpose",601 "status": "pending",602 "file": {603 "id": "id",604 "bytes": 0,605 "created_at": 0,606 "filename": "filename",607 "object": "file",608 "purpose": "assistants",609 "status": "uploaded",610 "expires_at": 0,611 "status_details": "status_details"612 },613 "object": "upload"614}615```616617### Example618619```http620curl https://api.openai.com/v1/uploads \621 -H "Authorization: Bearer $OPENAI_API_KEY" \622 -d '{623 "purpose": "fine-tune",624 "filename": "training_examples.jsonl",625 "bytes": 2147483648,626 "mime_type": "text/jsonl",627 "expires_after": {628 "anchor": "created_at",629 "seconds": 3600630 }631 }'632```633634#### Response635636```json637{638 "id": "upload_abc123",639 "object": "upload",640 "bytes": 2147483648,641 "created_at": 1719184911,642 "filename": "training_examples.jsonl",643 "purpose": "fine-tune",644 "status": "pending",645 "expires_at": 1719127296646}647```648649## Domain Types650651### Upload652653- `Upload object { id, bytes, created_at, 6 more }`654655 The Upload object can accept byte chunks in the form of Parts.656657 - `id: string`658659 The Upload unique identifier, which can be referenced in API endpoints.660661 - `bytes: number`662663 The intended number of bytes to be uploaded.664665 - `created_at: number`666667 The Unix timestamp (in seconds) for when the Upload was created.668669 - `expires_at: number`670671 The Unix timestamp (in seconds) for when the Upload will expire.672673 - `filename: string`674675 The name of the file to be uploaded.676677 - `purpose: string`678679 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.680681 - `status: "pending" or "completed" or "cancelled" or "expired"`682683 The status of the Upload.684685 - `"pending"`686687 - `"completed"`688689 - `"cancelled"`690691 - `"expired"`692693 - `file: optional FileObject or null`694695 The `File` object represents a document that has been uploaded to OpenAI.696697 - `id: string`698699 The file identifier, which can be referenced in the API endpoints.700701 - `bytes: number`702703 The size of the file, in bytes.704705 - `created_at: number`706707 The Unix timestamp (in seconds) for when the file was created.708709 - `filename: string`710711 The name of the file.712713 - `object: "file"`714715 The object type, which is always `file`.716717 - `"file"`718719 - `purpose: "assistants" or "assistants_output" or "batch" or 5 more`720721 The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`, `vision`, and `user_data`.722723 - `"assistants"`724725 - `"assistants_output"`726727 - `"batch"`728729 - `"batch_output"`730731 - `"fine-tune"`732733 - `"fine-tune-results"`734735 - `"vision"`736737 - `"user_data"`738739 - `status: "uploaded" or "processed" or "error"`740741 Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.742743 - `"uploaded"`744745 - `"processed"`746747 - `"error"`748749 - `expires_at: optional number`750751 The Unix timestamp (in seconds) for when the file will expire.752753 - `status_details: optional string`754755 Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`.756757 - `object: optional "upload"`758759 The object type, which is always "upload".760761 - `"upload"`762763# Parts764765## Add upload part766767**post** `/uploads/{upload_id}/parts`768769Adds a [Part](/api/reference/resources/uploads/subresources/parts) to an [Upload](/api/reference/resources/uploads) object. A Part represents a chunk of bytes from the file you are trying to upload.770771Each Part can be at most 64 MB, and you can add Parts until you hit the Upload maximum of 8 GB.772773It is possible to add multiple Parts in parallel. You can decide the intended order of the Parts when you [complete the Upload](/api/reference/resources/uploads/methods/complete).774775### Path Parameters776777- `upload_id: string`778779### Returns780781- `UploadPart object { id, created_at, object, upload_id }`782783 The upload Part represents a chunk of bytes we can add to an Upload object.784785 - `id: string`786787 The upload Part unique identifier, which can be referenced in API endpoints.788789 - `created_at: number`790791 The Unix timestamp (in seconds) for when the Part was created.792793 - `object: "upload.part"`794795 The object type, which is always `upload.part`.796797 - `"upload.part"`798799 - `upload_id: string`800801 The ID of the Upload object that this Part was added to.802803### Example804805```http806curl https://api.openai.com/v1/uploads/$UPLOAD_ID/parts \807 -H 'Content-Type: multipart/form-data' \808 -H "Authorization: Bearer $OPENAI_API_KEY" \809 -F 'data=@/path/to/data'810```811812#### Response813814```json815{816 "id": "id",817 "created_at": 0,818 "object": "upload.part",819 "upload_id": "upload_id"820}821```822823### Example824825```http826curl https://api.openai.com/v1/uploads/upload_abc123/parts827 -F data="aHR0cHM6Ly9hcGkub3BlbmFpLmNvbS92MS91cGxvYWRz..."828```829830#### Response831832```json833{834 "id": "part_def456",835 "object": "upload.part",836 "created_at": 1719185911,837 "upload_id": "upload_abc123"838}839```840841## Domain Types842843### Upload Part844845- `UploadPart object { id, created_at, object, upload_id }`846847 The upload Part represents a chunk of bytes we can add to an Upload object.848849 - `id: string`850851 The upload Part unique identifier, which can be referenced in API endpoints.852853 - `created_at: number`854855 The Unix timestamp (in seconds) for when the Part was created.856857 - `object: "upload.part"`858859 The object type, which is always `upload.part`.860861 - `"upload.part"`862863 - `upload_id: string`864865 The ID of the Upload object that this Part was added to.866