上传文件
流式上传文档、媒体或 UTF-8 文本文件,单文件最多 100 MB。
/openai/v1/files◐ 部分支持请求体
filestring必填The File object (not file name) to be uploaded.
已验证生效。
purposestring必填◐ 部分支持文件用途:user_data、assistants 或 vision(vision 只接受 PNG、JPEG、GIF、WebP 图片)。OpenAI 的 batch、fine-tune、evals 等其余用途不支持,返回 400 PURPOSE_UNSUPPORTED。
支持 user_data、assistants、vision;batch、fine-tune、evals 等其余值返回 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,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).
返回
200 file
单文件最多 100 MB(104857600 字节);按内容识别 PDF、Office、图片、音频、视频与 UTF-8 文本。purpose 支持 user_data / assistants / vision;其他用途、空文件、不支持类型和超限均返回 400。不支持 Uploads 分片。只接受表单 file、purpose、expires_after[anchor]、expires_after[seconds];其他表单字段或任何查询参数返回 400 invalid_request_error,消息为 "Unrecognized request argument supplied: <字段>",param 为该字段。
错误按 OpenAI 格式返回,参见 错误码
响应
HTTP 200
OK
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| 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`. |