OpenAI 列出向量存储文件接口
列出向量存储文件
get /vector_stores/{vector_store_id}/files
返回向量存储文件列表。
路径参数
vector_store_id: string:此请求涉及的向量存储 ID。
查询参数
after: optional string
分页游标。after是定义列表当前位置的对象ID。例如,某次列表请求返回100个对象,最后一个为obj_foo,后续请求可包含after=obj_foo,获取下一页。
before: optional string
分页游标。before是定义列表当前位置的对象ID。例如,某次列表请求返回100个对象,第一个为obj_foo,后续请求可包含before=obj_foo,获取上一页。
filter: optional "in_progress" or "completed" or "failed" or "cancelled"
按文件状态筛选,可为in_progress、completed、failed或cancelled。
"in_progress"
"completed"
"failed"
"cancelled"
limit: optional integer(默认 20)
返回对象数量上限,范围1到100,默认为20。
order: optional "asc" or "desc"(默认"desc")
按对象的created_at时间戳排序。asc表示升序,desc表示降序。
"asc"
"desc"
返回值
data: array of VectorStoreFile
id: string
标识符,可在API端点中引用。
created_at: integer(Unix 时间戳)
向量存储文件创建时的Unix时间戳,单位为秒。
last_error: object { code, message } or null
与此向量存储文件关联的最近一次错误。没有错误时为null。
code: "server_error" or "unsupported_file" or "invalid_file"
可为server_error、unsupported_file或invalid_file。
"server_error"
"unsupported_file"
"invalid_file"
message: string
供人阅读的错误描述。
object: "vector_store.file"
对象类型,固定为vector_store.file。
"vector_store.file"
status: "in_progress" or "completed" or "cancelled" or "failed"
向量存储文件的状态,可为in_progress、completed、cancelled或failed。completed表示该向量存储文件已可使用。
"in_progress"
"completed"
"cancelled"
"failed"
usage_bytes: integer
向量存储总用量,单位为字节。注意,此值可能与原始文件大小不同。
vector_store_id: string
attributes: optional map[string or number or boolean] or null
可附加到对象的一组16个键值对,可用于以结构化格式保存额外信息,并通过API或控制台查询对象。键为最长64个字符的字符串;值可以是最长512个字符的字符串、布尔值或数字。
string(最长 512 个字符)
number
boolean
chunking_strategy: optional StaticFileChunkingStrategyObject or OtherFileChunkingStrategyObject
用于对文件分块的策略。
StaticFileChunkingStrategyObject object { static, type }
static: StaticFileChunkingStrategy
chunk_overlap_tokens: integer
相邻块之间重叠的词元数,默认值为400。
注意,重叠量不能超过max_chunk_size_tokens的一半。
max_chunk_size_tokens: integer(范围为 100 至 4096)
每个块的最大词元数,默认值为800,最小值为100,最大值为4096。
type: "static"
固定为static。
"static"
OtherFileChunkingStrategyObject object { type }
分块策略未知时返回此类型。通常是因为文件在API引入chunking_strategy概念之前就已建立索引。
type: "other"
固定为other。
"other"
first_id: string
has_more: boolean
last_id: string
object: string
示例
## [中文] 发送GET请求;将示例API凭证及资源标识替换为应用使用的值。
curl https://api.openai.com/v1/vector_stores/$VECTOR_STORE_ID/files \
-H 'OpenAI-Beta: assistants=v2' \
-H "Authorization: Bearer $OPENAI_API_KEY"
响应
中文说明:以下为原文配置、命令或事件示例,字段名、枚举、标识符及数值保留。
{
"data": [
{
"id": "id",
"created_at": 0,
"last_error": {
"code": "server_error",
"message": "message"
},
"object": "vector_store.file",
"status": "in_progress",
"usage_bytes": 0,
"vector_store_id": "vector_store_id",
"attributes": {
"foo": "string"
},
"chunking_strategy": {
"static": {
"chunk_overlap_tokens": 0,
"max_chunk_size_tokens": 100
},
"type": "static"
}
}
],
"first_id": "file-abc123",
"has_more": false,
"last_id": "file-abc456",
"object": "list"
}
示例
## [中文] 发送GET请求;将示例API凭证及资源标识替换为应用使用的值。
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"
响应
中文说明:以下为原文配置、命令或事件示例,字段名、枚举、标识符及数值保留。
{
"object": "list",
"data": [
{
"id": "file-abc123",
"object": "vector_store.file",
"created_at": 1699061776,
"vector_store_id": "vs_abc123",
"usage_bytes": 1234,
"status": "completed",
"last_error": null
},
{
"id": "file-abc456",
"object": "vector_store.file",
"created_at": 1699061776,
"vector_store_id": "vs_abc123",
"usage_bytes": 1234,
"status": "completed",
"last_error": null
}
],
"first_id": "file-abc123",
"last_id": "file-abc456",
"has_more": false
}
TRAE-AI编程


更多建议: