矢量存储文件
试用版

矢量存储文件表示矢量存储中的文件。source

相关指南: 文件搜索source

创建矢量存储文件
试用版

发布 https://api.openai.com/v1/vector_stores/{vector_store_id}/files

通过将 File 附加到矢量存储来创建矢量存储文件。source

路径参数

要为其创建 File 的向量存储的 ID。source

请求正文

矢量存储应使用的文件 ID。适用于以下工具file_search可以访问文件。source

用于对文件进行分块的分块策略。如果未设置,将使用auto策略。source

示例请求
1
2
3
4
5
6
7
curl https://api.openai.com/v1/vector_stores/vs_abc123/files \
    -H "Authorization: Bearer $OPENAI_API_KEY" \
    -H "Content-Type: application/json" \
    -H "OpenAI-Beta: assistants=v2" \
    -d '{
      "file_id": "file-abc123"
    }'
响应
1
2
3
4
5
6
7
8
9
{
  "id": "file-abc123",
  "object": "vector_store.file",
  "created_at": 1699061776,
  "usage_bytes": 1234,
  "vector_store_id": "vs_abcd",
  "status": "completed",
  "last_error": null
}

列出向量存储文件
试用版

获取 https://api.openai.com/v1/vector_stores/{vector_store_id}/files

返回矢量存储文件的列表。source

路径参数

文件所属的矢量存储的 ID。source

查询参数

要返回的对象数量限制。Limit 的范围可以介于 1 和 100 之间,默认值为 20。source

created_at对象的时间戳。asc对于升序和desc以降序排列。source

用于分页的游标。after是定义您在列表中的位置的对象 ID。例如,如果您发出列表请求并收到 100 个对象,以 obj_foo 结尾,则您的后续调用可以包含 after=obj_foo 以便获取列表的下一页。source

用于分页的游标。before是定义您在列表中的位置的对象 ID。例如,如果您发出一个列表请求并收到 100 个对象,以 obj_foo 开头,则您的后续调用可以包含 before=obj_foo 以便获取列表的上一页。source

按文件状态筛选。其中之一in_progress,completed,failed,cancelled.source

返回

矢量存储文件对象的列表。source

示例请求
1
2
3
4
curl https://api.openai.com/v1/vector_stores/vs_abc123/files \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -H "OpenAI-Beta: assistants=v2"
响应
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{
  "object": "list",
  "data": [
    {
      "id": "file-abc123",
      "object": "vector_store.file",
      "created_at": 1699061776,
      "vector_store_id": "vs_abc123"
    },
    {
      "id": "file-abc456",
      "object": "vector_store.file",
      "created_at": 1699061776,
      "vector_store_id": "vs_abc123"
    }
  ],
  "first_id": "file-abc123",
  "last_id": "file-abc456",
  "has_more": false
}

检索向量存储文件
试用版

获取 https://api.openai.com/v1/vector_stores/{vector_store_id}/files/{file_id}

检索向量存储文件。source

路径参数

文件所属的向量存储的 ID。source

正在检索的文件的 ID。source

示例请求
1
2
3
4
curl https://api.openai.com/v1/vector_stores/vs_abc123/files/file-abc123 \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -H "OpenAI-Beta: assistants=v2"
响应
1
2
3
4
5
6
7
8
{
  "id": "file-abc123",
  "object": "vector_store.file",
  "created_at": 1699061776,
  "vector_store_id": "vs_abcd",
  "status": "completed",
  "last_error": null
}

删除 vector store 文件
试用版

删除 https://api.openai.com/v1/vector_stores/{vector_store_id}/files/{file_id}

删除 vector store 文件。这将从矢量存储中删除文件,但不会删除文件本身。要删除文件,请使用 delete file 端点。source

路径参数

文件所属的向量存储的 ID。source

要删除的文件的 ID。source

返回

删除状态source

示例请求
1
2
3
4
5
curl https://api.openai.com/v1/vector_stores/vs_abc123/files/file-abc123 \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -H "OpenAI-Beta: assistants=v2" \
  -X DELETE
响应
1
2
3
4
5
{
  id: "file-abc123",
  object: "vector_store.file.deleted",
  deleted: true
}

矢量存储文件对象
试用版

附加到矢量存储的文件列表。source

标识符,可在 API 终端节点中引用。source

对象类型,始终为vector_store.file.source

矢量存储总使用量(以字节为单位)。请注意,这可能与原始文件大小不同。source

创建向量存储文件时的 Unix 时间戳(以秒为单位)。source

向量存储文件的状态,可以是in_progress,completed,cancelledfailed.状态completed表示 Vector Store 文件已准备就绪,可供使用。source

与此 vector store 文件关联的最后一个错误。将是null如果没有错误。source

用于对文件进行分块的策略。source

OBJECT 向量存储文件对象
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{
  "id": "file-abc123",
  "object": "vector_store.file",
  "usage_bytes": 1234,
  "created_at": 1698107661,
  "vector_store_id": "vs_abc123",
  "status": "completed",
  "last_error": null,
  "chunking_strategy": {
    "type": "static",
    "static": {
      "max_chunk_size_tokens": 800,
      "chunk_overlap_tokens": 400
    }
  }
}