# OpenAI/文件(Files)

# POST 上传文件

POST /v1/files

上传可跨各种端点/功能使用的文件。一个组织上传的所有文件大小最大可达 100 GB。

单个文件的大小最大为 512MB。请参阅助手工具指南 (opens new window)以了解有关支持的文件类型的更多信息。Fine-tuning API 仅支持.jsonl文件。

如果您需要增加这些存储限制,请联系我们。 (opens new window)

Body 请求参数

file: string
purpose: fine-tune

# 请求参数

名称 位置 类型 必选 说明
Authorization header string none
body body object none
» file body string(binary) 要上传的JSONL (opens new window)文件的名称。
» purpose body string 上传文件的预期目的。

# 详细说明

» file: 要上传的JSONL (opens new window)文件的名称。

如果purpose设置为“微调”,则每一行都是一个 JSON 记录,其中包含代表您的训练示例 (opens new window)的“提示”和“完成”字段。

» purpose: 上传文件的预期目的。

使用“fine-tune”进行微调 (opens new window),使用“assistants”进行助手 (opens new window)消息 (opens new window)。这使我们能够验证上传文件的格式是否正确以进行微调。

返回示例

成功

{
  "id": "file-BK7bzQj3FfZFXr7DbL6xJwfo",
  "object": "file",
  "bytes": 120000,
  "created_at": 1677610602,
  "filename": "mydata.jsonl",
  "purpose": "fine-tune"
}

# 返回结果

状态码 状态码含义 说明 数据模型
200 OK (opens new window) 成功 Inline

# 返回数据结构

状态码 200

名称 类型 必选 约束 中文名 说明
» id string true none none
» object string true none none
» bytes integer true none none
» created_at integer true none none
» filename string true none none
» purpose string true none none

# DELETE 删除文件

DELETE /v1/files/{file_id}

删除文件。

# 请求参数

名称 位置 类型 必选 说明
file_id path string 用于此请求的文件的 ID。
Authorization header string none

返回示例

成功

{
  "id": "file-abc123",
  "object": "file",
  "deleted": true
}

# 返回结果

状态码 状态码含义 说明 数据模型
200 OK (opens new window) 成功 Inline

# 返回数据结构

状态码 200

名称 类型 必选 约束 中文名 说明
» id string true none none
» object string true none none
» deleted boolean true none none

# GET 检索文件

GET /v1/files/{file_id}

返回有关特定文件的信息。

# 请求参数

名称 位置 类型 必选 说明
file_id path string 用于此请求的文件的 ID。
Authorization header string none

返回示例

成功

{
  "id": "file-BK7bzQj3FfZFXr7DbL6xJwfo",
  "object": "file",
  "bytes": 120000,
  "created_at": 1677610602,
  "filename": "mydata.jsonl",
  "purpose": "fine-tune"
}

# 返回结果

状态码 状态码含义 说明 数据模型
200 OK (opens new window) 成功 Inline

# 返回数据结构

状态码 200

名称 类型 必选 约束 中文名 说明
» id string true none none
» object string true none none
» bytes integer true none none
» created_at integer true none none
» filename string true none none
» purpose string true none none

# GET 检索文件内容

GET /v1/files/{file_id}/content

# 请求参数

名称 位置 类型 必选 说明
file_id path string 用于此请求的文件的 ID。
Authorization header string none

返回示例

200 Response

{}

# 返回结果

状态码 状态码含义 说明 数据模型
200 OK (opens new window) 成功 Inline

# 返回数据结构

# GET 列出文件

GET /v1/files%2520_

# 请求参数

名称 位置 类型 必选 说明
purpose query string Only return files with the given purpose.
Authorization header string none

# 详细说明

purpose: Only return files with the given purpose.

返回示例

成功

{
  "data": [
    {
      "id": "file-abc123",
      "object": "file",
      "bytes": 175,
      "created_at": 1613677385,
      "filename": "salesOverview.pdf",
      "purpose": "assistants"
    },
    {
      "id": "file-abc123",
      "object": "file",
      "bytes": 140,
      "created_at": 1613779121,
      "filename": "puppy.jsonl",
      "purpose": "fine-tune"
    }
  ],
  "object": "list"
}

# 返回结果

状态码 状态码含义 说明 数据模型
200 OK (opens new window) 成功 Inline

# 返回数据结构

状态码 200

名称 类型 必选 约束 中文名 说明
» data [object] true none none
»» id string true none none
»» object string true none none
»» bytes integer true none none
»» created_at integer true none none
»» filename string true none none
»» purpose string true none none
» object string true none none