文件

上传文件

流式上传文件,按内容识别类型,单文件最多 100 MB。

POST /file/v1/files◐ 部分支持

OpenAI 官方文档 ↗

请求体

  • filestring必填

    The File object (not file name) to be uploaded.

  • purposestring必填

    The file purpose: user_data, assistants or vision.

    取值 user_dataassistantsvision
  • expires_afterobject可选

    Optional expiry relative to created_at. Files without an expiry persist until deleted.

    ▸ 展开子字段(2)
    • anchorstring必填

      Anchor timestamp after which the expiration policy applies. Supported anchors: `created_at`.

      取值 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).

  • praxisobject可选

    Own-face extensions. Use at most one expiry setting.

    ▸ 展开子字段(1)
    • expires_in_secondsinteger可选

      Expiry up to 90 days (Anthropic union). Mutually exclusive with expires_after.

返回

200 file

支持 PDF、DOCX / XLSX / PPTX、PNG / JPEG / GIF / WebP、MP3 / WAV / FLAC / OGG / M4A、MP4 / WebM,以及 UTF-8 JSON / NDJSON / CSV / Markdown / 纯文本。purpose 支持 user_data / assistants / vision。上限 104857600 字节;空文件、类型不支持、用途不支持、超限均返回 400。不提供 Uploads 分片。可用 expires_after[anchor] 与 expires_after[seconds] 或 praxis[expires_in_seconds] 设置有效期,两组互斥。

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

OK

application/json

名称类型说明
idstringThe file identifier, which can be referenced in the API endpoints.
bytesintegerThe size of the file, in bytes.
created_atintegerThe Unix timestamp (in seconds) for when the file was created.
expires_atintegerThe Unix timestamp (in seconds) for when the file will expire.
filenamestringThe name of the file.
objectstringThe object type, which is always `file`.
purposestringUpload purpose. Image references in conversations require user_data.
statusstringDeprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.
status_detailsstring | nullDeprecated; always null or absent.
mime_typestringContent-detected MIME type.
downloadablebooleanTenant-owned live files can be downloaded through this face.
scopeobjectPresent for session output files.
scope.typestringKind of scope; always `session`.
scope.idstringId of the session the file belongs to.
relative_pathstringPath within the session output directory; present for session outputs.
revisionintegerSession output revision; present for session outputs.