OpenAI 列出向量存储接口

2026-11-10 18:17 更新

列出向量存储

get /vector_stores

返回向量存储列表。

查询参数

  • after: optional string

分页游标。after是定义列表当前位置的对象ID。例如,某次列表请求返回100个对象,最后一个为obj_foo,后续请求可包含after=obj_foo,获取下一页。

  • before: optional string

分页游标。before是定义列表当前位置的对象ID。例如,某次列表请求返回100个对象,第一个为obj_foo,后续请求可包含before=obj_foo,获取上一页。

  • limit: optional integer(默认 20)

返回对象数量上限,范围1到100,默认为20。

  • order: optional "asc" or "desc"(默认 "desc")

按对象的created_at时间戳排序。asc表示升序,desc表示降序。

  • "asc"

  • "desc"

返回值

  • data: array of VectorStore

  • id: string

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

  • created_at: integer(Unix 时间戳)

向量存储创建时的Unix时间戳,单位为秒。

  • file_counts: object { cancelled, completed, failed, 2 more }

  • cancelled: integer

已取消的文件数量。

  • completed: integer

已成功处理的文件数量。

  • failed: integer

处理失败的文件数量。

  • in_progress: integer

正在处理的文件数量。

  • total: integer

文件总数。

  • last_active_at: integer or null(Unix 时间戳)

向量存储最后活跃时的Unix时间戳,单位为秒。

  • metadata: Metadata or null

可附加到对象的一组16个键值对,用于结构化保存附加信息,并通过API或控制台查询对象。

键为最长64个字符的字符串,值为最长512个字符的字符串。

  • name: string

向量存储的名称。

  • object: "vector_store"

对象类型,固定为vector_store。

  • "vector_store"

  • status: "expired" or "in_progress" or "completed"

向量存储的状态,可为expired、in_progress或completed。completed表示向量存储已可使用。

  • "expired"

  • "in_progress"

  • "completed"

  • usage_bytes: integer

向量存储中的文件使用的总字节数。

  • expires_after: optional object { anchor, days }

向量存储的过期策略。

  • anchor: "last_active_at"

过期策略所依据的起算时间戳。支持的起算点为last_active_at。

  • "last_active_at"

  • days: integer(范围为 1 至 365)

向量存储在起算时间之后经过多少天过期。

  • expires_at: optional integer or null(Unix 时间戳)

向量存储过期时的Unix时间戳,单位为秒。

  • first_id: string

  • has_more: boolean

  • last_id: string

  • object: string

示例

## [中文] 发送GET请求;将示例API凭证及资源标识替换为应用使用的值。
curl https://api.openai.com/v1/vector_stores \
    -H 'OpenAI-Beta: assistants=v2' \
    -H "Authorization: Bearer $OPENAI_API_KEY"

响应

中文说明:以下为原文配置、命令或事件示例,字段名、枚举、标识符及数值保留。

{
  "data": [
    {
      "id": "id",
      "created_at": 0,
      "file_counts": {
        "cancelled": 0,
        "completed": 0,
        "failed": 0,
        "in_progress": 0,
        "total": 0
      },
      "last_active_at": 0,
      "metadata": {
        "foo": "string"
      },
      "name": "name",
      "object": "vector_store",
      "status": "expired",
      "usage_bytes": 0,
      "expires_after": {
        "anchor": "last_active_at",
        "days": 1
      },
      "expires_at": 0
    }
  ],
  "first_id": "vs_abc123",
  "has_more": false,
  "last_id": "vs_abc456",
  "object": "list"
}

示例

## [中文] 发送GET请求;将示例API凭证及资源标识替换为应用使用的值。
curl https://api.openai.com/v1/vector_stores \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -H "OpenAI-Beta: assistants=v2"

响应

中文说明:以下为原文配置、命令或事件示例,字段名、枚举、标识符及数值保留。

代码内文字译释:

  • 客服常见问题。
  • 包含按主题整理的常见问题与解答。
  • 客服常见问题第2版。

{
  "object": "list",
  "data": [
    {
      "id": "vs_abc123",
      "object": "vector_store",
      "created_at": 1699061776,
      "name": "Support FAQ",
      "description": "Contains commonly asked questions and answers, organized by topic.",
      "file_counts": {
        "in_progress": 0,
        "completed": 3,
        "failed": 0,
        "cancelled": 0,
        "total": 3
      },
      "usage_bytes": 139920,
      "status": "completed",
      "last_active_at": null,
      "metadata": {}
    },
    {
      "id": "vs_abc456",
      "object": "vector_store",
      "created_at": 1699061776,
      "name": "Support FAQ v2",
      "file_counts": {
        "in_progress": 0,
        "completed": 3,
        "failed": 0,
        "cancelled": 0,
        "total": 3
      },
      "usage_bytes": 139920,
      "status": "completed",
      "last_active_at": null,
      "metadata": {}
    }
  ],
  "first_id": "vs_abc123",
  "last_id": "vs_abc456",
  "has_more": false
}
以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号