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. Uploads to this endpoint are rate-limited to 1,000 requests per minu
(
self,
*,
file: FileTypes,
purpose: FilePurpose,
expires_after: file_create_params.ExpiresAfter | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
)
| 412 | return AsyncFilesWithStreamingResponse(self) |
| 413 | |
| 414 | async def create( |
| 415 | self, |
| 416 | *, |
| 417 | file: FileTypes, |
| 418 | purpose: FilePurpose, |
| 419 | expires_after: file_create_params.ExpiresAfter | Omit = omit, |
| 420 | # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 421 | # The extra values given here take precedence over values defined on the client or passed to this method. |
| 422 | extra_headers: Headers | None = None, |
| 423 | extra_query: Query | None = None, |
| 424 | extra_body: Body | None = None, |
| 425 | timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 426 | ) -> FileObject: |
| 427 | """Upload a file that can be used across various endpoints. |
| 428 | |
| 429 | Individual files can be |
| 430 | up to 512 MB, and each project can store up to 2.5 TB of files in total. There |
| 431 | is no organization-wide storage limit. Uploads to this endpoint are rate-limited |
| 432 | to 1,000 requests per minute per authenticated user. |
| 433 | |
| 434 | - The Assistants API supports files up to 2 million tokens and of specific file |
| 435 | types. See the |
| 436 | [Assistants Tools guide](https://platform.openai.com/docs/assistants/tools) |
| 437 | for details. |
| 438 | - The Fine-tuning API only supports `.jsonl` files. The input also has certain |
| 439 | required formats for fine-tuning |
| 440 | [chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input) |
| 441 | or |
| 442 | [completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input) |
| 443 | models. |
| 444 | - The Batch API only supports `.jsonl` files up to 200 MB in size. The input |
| 445 | also has a specific required |
| 446 | [format](https://platform.openai.com/docs/api-reference/batch/request-input). |
| 447 | - For Retrieval or `file_search` ingestion, upload files here first. If you need |
| 448 | to attach multiple uploaded files to the same vector store, use |
| 449 | [`/vector_stores/{vector_store_id}/file_batches`](https://platform.openai.com/docs/api-reference/vector-stores-file-batches/createBatch) |
| 450 | instead of attaching them one by one. Vector store attachment has separate |
| 451 | limits from file upload, including 2,000 attached files per minute per |
| 452 | organization. |
| 453 | |
| 454 | Please [contact us](https://help.openai.com/) if you need to increase these |
| 455 | storage limits. |
| 456 | |
| 457 | Args: |
| 458 | file: The File object (not file name) to be uploaded. |
| 459 | |
| 460 | purpose: |
| 461 | The intended purpose of the uploaded file. One of: |
| 462 | |
| 463 | - `assistants`: Used in the Assistants API |
| 464 | - `batch`: Used in the Batch API |
| 465 | - `fine-tune`: Used for fine-tuning |
| 466 | - `vision`: Images used for vision fine-tuning |
| 467 | - `user_data`: Flexible file type for any purpose |
| 468 | - `evals`: Used for eval data sets |
| 469 | |
| 470 | expires_after: The expiration policy for a file. By default, files with `purpose=batch` expire |
| 471 | after 30 days and all other files are persisted until they are manually deleted. |
nothing calls this directly
no test coverage detected