OpenAI 创建向量存储接口
创建向量存储
post /vector_stores
创建向量存储。
请求体参数
媒体类型为 application/json。
chunking_strategy: optional AutoFileChunkingStrategyParam or StaticFileChunkingStrategyObjectParam
用于对文件分块的策略。未设置时使用auto策略。仅在file_ids非空时适用。
AutoFileChunkingStrategyParam object { type }
默认策略。目前使用max_chunk_size_tokens为800、chunk_overlap_tokens为400的设置。
type: "auto"
固定为auto。
"auto"
StaticFileChunkingStrategyObjectParam 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"
description: optional string
向量存储的描述,可用于说明其用途。
expires_after: optional object { anchor, days }
向量存储的过期策略。
anchor: "last_active_at"
过期策略所依据的起算时间戳。支持的起算点为last_active_at。
"last_active_at"
days: integer(范围为 1 至 365)
向量存储在起算时间之后经过多少天过期。
file_ids: optional array of string(最多 500 项)
向量存储应使用的File ID列表,适用于file_search等可访问文件的工具。
metadata: optional Metadata or null
可附加到对象的一组16个键值对,用于结构化保存附加信息,并通过API或控制台查询对象。
键为最长64个字符的字符串,值为最长512个字符的字符串。
name: optional string
向量存储的名称。
返回值
VectorStore object { id, created_at, file_counts, 8 more }
向量存储是已处理文件的集合,可供file_search工具使用。
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时间戳,单位为秒。
示例
## [中文] 发送POST请求;将示例API凭证及资源标识替换为应用使用的值。
curl https://api.openai.com/v1/vector_stores \
-H 'Content-Type: application/json' \
-H 'OpenAI-Beta: assistants=v2' \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{}'
响应
中文说明:以下为原文配置、命令或事件示例,字段名、枚举、标识符及数值保留。
{
"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
}
示例
代码内文字译释:
- 客服常见问题。
## [中文] 发送POST请求;将示例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" \
-d '{
"name": "Support FAQ"
}'
响应
中文说明:以下为原文配置、命令或事件示例,字段名、枚举、标识符及数值保留。
代码内文字译释:
- 客服常见问题。
- 包含按主题整理的常见问题与解答。
{
"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": 0,
"failed": 0,
"cancelled": 0,
"total": 0
},
"usage_bytes": 0,
"status": "completed",
"last_active_at": null,
"metadata": {}
}
TRAE-AI编程


更多建议: