Upload a file
Stream a document, media or UTF-8 text file, up to 100 MB.
/openai/v1/files◐ PartialRequest body
filestring必填The File object (not file name) to be uploaded.
Verified to take effect.
purposestring必填◐ Partially supportedThe file purpose: user_data, assistants or vision (vision accepts only PNG, JPEG, GIF or WebP images). Other OpenAI purposes such as batch, fine-tune and evals are not supported and return 400 PURPOSE_UNSUPPORTED.
Supports user_data, assistants and vision; batch, fine-tune, evals and other values return 400.
expires_afterobject可选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.
anchor=created_at and seconds=3600–2592000.
▸ 展开子字段(2)
anchorstring必填Anchor timestamp after which the expiration policy applies. Supported anchors: `created_at`.
secondsinteger必填The number of seconds after the anchor time that the file will expire. Must be between 3600 (1 hour) and 2592000 (30 days).
Returns
200 file
Upload one file, up to 100 MB (104857600 bytes), using streaming multipart/form-data. Supported content-detected types: PDF; DOCX, XLSX, PPTX; PNG, JPEG, GIF, WebP; MP3, WAV, FLAC, OGG, M4A; MP4, WebM; UTF-8 JSON, NDJSON, CSV, Markdown and plain text. Purposes: user_data, assistants, vision. Other purposes and empty/unsupported/oversized files return 400. OpenAI Uploads chunking is not supported. expires_after accepts anchor created_at and seconds 3600–2592000. Only form file, purpose, expires_after[anchor] and expires_after[seconds] are accepted; any other form field or any query parameter returns 400 invalid_request_error "Unrecognized request argument supplied: <name>" with param naming it.
Errors follow the OpenAI format — see error codes
Response
HTTP 200
OK
application/json
| Name | Type | Description |
|---|---|---|
| id | string | The file identifier, which can be referenced in the API endpoints. |
| bytes | integer | The size of the file, in bytes. |
| created_at | integer | The Unix timestamp (in seconds) for when the file was created. |
| expires_at | integer | The Unix timestamp (in seconds) for when the file will expire. |
| filename | string | The name of the file. |
| object | string | The object type, which is always `file`. |
| purpose | string | The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`, `vision`, and `user_data`. |
| status | string | Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`. |
| status_details | string | Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`. |