矢量存储试用版
试用版
矢量存储用于存储文件以供file_search
工具。
相关指南: 文件搜索
创建矢量存储试用版
试用版
POST https://api.openai.com/v1/vector_stores
创建 vector store。
请求正文
矢量存储应使用的文件 ID 列表。适用于以下工具file_search
可以访问文件。
返回
矢量存储对象。
示例请求
1
2
3
4
5
6
7
curl https://api.openai.com/v1/vector_stores \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-H "OpenAI-Beta: assistants=v2"
-d '{
"name": "Support FAQ"
}'
响应
1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
"id": "vs_abc123",
"object": "vector_store",
"created_at": 1699061776,
"name": "Support FAQ",
"bytes": 139920,
"file_counts": {
"in_progress": 0,
"completed": 3,
"failed": 0,
"cancelled": 0,
"total": 3
}
}
列出向量存储试用版
试用版
获取 https://api.openai.com/v1/vector_stores
返回向量存储的列表。
查询参数
用于分页的游标。after
是定义您在列表中的位置的对象 ID。例如,如果您发出列表请求并收到 100 个对象,以 obj_foo 结尾,则您的后续调用可以包含 after=obj_foo 以便获取列表的下一页。
返回
矢量存储对象的列表。
示例请求
1
2
3
4
curl https://api.openai.com/v1/vector_stores \
-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
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{
"object": "list",
"data": [
{
"id": "vs_abc123",
"object": "vector_store",
"created_at": 1699061776,
"name": "Support FAQ",
"bytes": 139920,
"file_counts": {
"in_progress": 0,
"completed": 3,
"failed": 0,
"cancelled": 0,
"total": 3
}
},
{
"id": "vs_abc456",
"object": "vector_store",
"created_at": 1699061776,
"name": "Support FAQ v2",
"bytes": 139920,
"file_counts": {
"in_progress": 0,
"completed": 3,
"failed": 0,
"cancelled": 0,
"total": 3
}
}
],
"first_id": "vs_abc123",
"last_id": "vs_abc456",
"has_more": false
}
检索向量存储试用版
试用版
获取 https://api.openai.com/v1/vector_stores/{vector_store_id}
检索 vector store。
返回
与指定 ID 匹配的 vector store 对象。
示例请求
1
2
3
4
curl https://api.openai.com/v1/vector_stores/vs_abc123 \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-H "OpenAI-Beta: assistants=v2"
响应
1
2
3
4
5
{
"id": "vs_abc123",
"object": "vector_store",
"created_at": 1699061776
}
修改向量存储试用版
试用版
示例请求
1
2
3
4
5
6
7
curl https://api.openai.com/v1/vector_stores/vs_abc123 \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-H "OpenAI-Beta: assistants=v2"
-d '{
"name": "Support FAQ"
}'
响应
1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
"id": "vs_abc123",
"object": "vector_store",
"created_at": 1699061776,
"name": "Support FAQ",
"bytes": 139920,
"file_counts": {
"in_progress": 0,
"completed": 3,
"failed": 0,
"cancelled": 0,
"total": 3
}
}
删除 vector store试用版
试用版
删除 https://api.openai.com/v1/vector_stores/{vector_store_id}
删除 vector store。
返回
删除状态
示例请求
1
2
3
4
5
curl https://api.openai.com/v1/vector_stores/vs_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: "vs_abc123",
object: "vector_store.deleted",
deleted: true
}
向量存储对象试用版
试用版
向量存储是已处理文件的集合,可供file_search
工具。
OBJECT 向量存储对象
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{
"id": "vs_123",
"object": "vector_store",
"created_at": 1698107661,
"usage_bytes": 123456,
"last_active_at": 1698107661,
"name": "my_vector_store",
"status": "completed",
"file_counts": {
"in_progress": 0,
"completed": 100,
"cancelled": 0,
"failed": 0,
"total": 100
},
"metadata": {},
"last_used_at": 1698107661
}