Vector Stores
List vector stores
get /vector_stores
List vector stores
Query Parameters
-
after: optional stringA cursor for use in pagination.
afteris an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. -
before: optional stringA cursor for use in pagination.
beforeis an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. -
limit: optional numberA limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
-
order: optional "asc" or "desc"Sort order by the
created_attimestamp of the objects.ascfor ascending order anddescfor descending order.-
"asc" -
"desc"
-
Returns
-
data: array of VectorStore-
id: stringThe identifier, which can be referenced in API endpoints.
-
created_at: numberThe Unix timestamp (in seconds) for when the vector store was created.
-
file_counts: object { cancelled, completed, failed, 2 more }-
cancelled: numberThe number of files that were cancelled.
-
completed: numberThe number of files that have been successfully processed.
-
failed: numberThe number of files that have failed to process.
-
in_progress: numberThe number of files that are currently being processed.
-
total: numberThe total number of files.
-
-
last_active_at: numberThe Unix timestamp (in seconds) for when the vector store was last active.
-
metadata: MetadataSet of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard.
Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.
-
name: stringThe name of the vector store.
-
object: "vector_store"The object type, which is always
vector_store."vector_store"
-
status: "expired" or "in_progress" or "completed"The status of the vector store, which can be either
expired,in_progress, orcompleted. A status ofcompletedindicates that the vector store is ready for use.-
"expired" -
"in_progress" -
"completed"
-
-
usage_bytes: numberThe total number of bytes used by the files in the vector store.
-
expires_after: optional object { anchor, days }The expiration policy for a vector store.
-
anchor: "last_active_at"Anchor timestamp after which the expiration policy applies. Supported anchors:
last_active_at."last_active_at"
-
days: numberThe number of days after the anchor time that the vector store will expire.
-
-
expires_at: optional numberThe Unix timestamp (in seconds) for when the vector store will expire.
-
-
first_id: string -
has_more: boolean -
last_id: string -
object: string
Example
curl https://api.openai.com/v1/vector_stores \
-H 'OpenAI-Beta: assistants=v2' \
-H "Authorization: Bearer $OPENAI_API_KEY"
Response
{
"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"
}
Example
curl https://api.openai.com/v1/vector_stores \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-H "OpenAI-Beta: assistants=v2"
Response
{
"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.",
"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",
"description": null,
"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
}
Create vector store
post /vector_stores
Create vector store
Body Parameters
-
chunking_strategy: optional FileChunkingStrategyParamThe chunking strategy used to chunk the file(s). If not set, will use the
autostrategy. Only applicable iffile_idsis non-empty.-
AutoFileChunkingStrategyParam object { type }The default strategy. This strategy currently uses a
max_chunk_size_tokensof800andchunk_overlap_tokensof400.-
type: "auto"Always
auto."auto"
-
-
StaticFileChunkingStrategyObjectParam object { static, type }Customize your own chunking strategy by setting chunk size and chunk overlap.
-
static: StaticFileChunkingStrategy-
chunk_overlap_tokens: numberThe number of tokens that overlap between chunks. The default value is
400.Note that the overlap must not exceed half of
max_chunk_size_tokens. -
max_chunk_size_tokens: numberThe maximum number of tokens in each chunk. The default value is
800. The minimum value is100and the maximum value is4096.
-
-
type: "static"Always
static."static"
-
-
-
description: optional stringA description for the vector store. Can be used to describe the vector store's purpose.
-
expires_after: optional object { anchor, days }The expiration policy for a vector store.
-
anchor: "last_active_at"Anchor timestamp after which the expiration policy applies. Supported anchors:
last_active_at."last_active_at"
-
days: numberThe number of days after the anchor time that the vector store will expire.
-
-
file_ids: optional array of stringA list of File IDs that the vector store should use. Useful for tools like
file_searchthat can access files. -
metadata: optional MetadataSet of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard.
Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.
-
name: optional stringThe name of the vector store.
Returns
-
VectorStore object { id, created_at, file_counts, 8 more }A vector store is a collection of processed files can be used by the
file_searchtool.-
id: stringThe identifier, which can be referenced in API endpoints.
-
created_at: numberThe Unix timestamp (in seconds) for when the vector store was created.
-
file_counts: object { cancelled, completed, failed, 2 more }-
cancelled: numberThe number of files that were cancelled.
-
completed: numberThe number of files that have been successfully processed.
-
failed: numberThe number of files that have failed to process.
-
in_progress: numberThe number of files that are currently being processed.
-
total: numberThe total number of files.
-
-
last_active_at: numberThe Unix timestamp (in seconds) for when the vector store was last active.
-
metadata: MetadataSet of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard.
Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.
-
name: stringThe name of the vector store.
-
object: "vector_store"The object type, which is always
vector_store."vector_store"
-
status: "expired" or "in_progress" or "completed"The status of the vector store, which can be either
expired,in_progress, orcompleted. A status ofcompletedindicates that the vector store is ready for use.-
"expired" -
"in_progress" -
"completed"
-
-
usage_bytes: numberThe total number of bytes used by the files in the vector store.
-
expires_after: optional object { anchor, days }The expiration policy for a vector store.
-
anchor: "last_active_at"Anchor timestamp after which the expiration policy applies. Supported anchors:
last_active_at."last_active_at"
-
days: numberThe number of days after the anchor time that the vector store will expire.
-
-
expires_at: optional numberThe Unix timestamp (in seconds) for when the vector store will expire.
-
Example
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 '{}'
Response
{
"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
}
Example
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"
}'
Response
{
"id": "vs_abc123",
"object": "vector_store",
"created_at": 1699061776,
"name": "Support FAQ",
"description": "Contains commonly asked questions and answers, organized by topic.",
"bytes": 139920,
"file_counts": {
"in_progress": 0,
"completed": 3,
"failed": 0,
"cancelled": 0,
"total": 3
}
}
Retrieve vector store
get /vector_stores/{vector_store_id}
Retrieve vector store
Path Parameters
vector_store_id: string
Returns
-
VectorStore object { id, created_at, file_counts, 8 more }A vector store is a collection of processed files can be used by the
file_searchtool.-
id: stringThe identifier, which can be referenced in API endpoints.
-
created_at: numberThe Unix timestamp (in seconds) for when the vector store was created.
-
file_counts: object { cancelled, completed, failed, 2 more }-
cancelled: numberThe number of files that were cancelled.
-
completed: numberThe number of files that have been successfully processed.
-
failed: numberThe number of files that have failed to process.
-
in_progress: numberThe number of files that are currently being processed.
-
total: numberThe total number of files.
-
-
last_active_at: numberThe Unix timestamp (in seconds) for when the vector store was last active.
-
metadata: MetadataSet of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard.
Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.
-
name: stringThe name of the vector store.
-
object: "vector_store"The object type, which is always
vector_store."vector_store"
-
status: "expired" or "in_progress" or "completed"The status of the vector store, which can be either
expired,in_progress, orcompleted. A status ofcompletedindicates that the vector store is ready for use.-
"expired" -
"in_progress" -
"completed"
-
-
usage_bytes: numberThe total number of bytes used by the files in the vector store.
-
expires_after: optional object { anchor, days }The expiration policy for a vector store.
-
anchor: "last_active_at"Anchor timestamp after which the expiration policy applies. Supported anchors:
last_active_at."last_active_at"
-
days: numberThe number of days after the anchor time that the vector store will expire.
-
-
expires_at: optional numberThe Unix timestamp (in seconds) for when the vector store will expire.
-
Example
curl https://api.openai.com/v1/vector_stores/$VECTOR_STORE_ID \
-H 'OpenAI-Beta: assistants=v2' \
-H "Authorization: Bearer $OPENAI_API_KEY"
Response
{
"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
}
Example
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"
Response
{
"id": "vs_abc123",
"object": "vector_store",
"created_at": 1699061776
}
Modify vector store
post /vector_stores/{vector_store_id}
Modify vector store
Path Parameters
vector_store_id: string
Body Parameters
-
expires_after: optional object { anchor, days }The expiration policy for a vector store.
-
anchor: "last_active_at"Anchor timestamp after which the expiration policy applies. Supported anchors:
last_active_at."last_active_at"
-
days: numberThe number of days after the anchor time that the vector store will expire.
-
-
metadata: optional MetadataSet of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard.
Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.
-
name: optional stringThe name of the vector store.
Returns
-
VectorStore object { id, created_at, file_counts, 8 more }A vector store is a collection of processed files can be used by the
file_searchtool.-
id: stringThe identifier, which can be referenced in API endpoints.
-
created_at: numberThe Unix timestamp (in seconds) for when the vector store was created.
-
file_counts: object { cancelled, completed, failed, 2 more }-
cancelled: numberThe number of files that were cancelled.
-
completed: numberThe number of files that have been successfully processed.
-
failed: numberThe number of files that have failed to process.
-
in_progress: numberThe number of files that are currently being processed.
-
total: numberThe total number of files.
-
-
last_active_at: numberThe Unix timestamp (in seconds) for when the vector store was last active.
-
metadata: MetadataSet of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard.
Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.
-
name: stringThe name of the vector store.
-
object: "vector_store"The object type, which is always
vector_store."vector_store"
-
status: "expired" or "in_progress" or "completed"The status of the vector store, which can be either
expired,in_progress, orcompleted. A status ofcompletedindicates that the vector store is ready for use.-
"expired" -
"in_progress" -
"completed"
-
-
usage_bytes: numberThe total number of bytes used by the files in the vector store.
-
expires_after: optional object { anchor, days }The expiration policy for a vector store.
-
anchor: "last_active_at"Anchor timestamp after which the expiration policy applies. Supported anchors:
last_active_at."last_active_at"
-
days: numberThe number of days after the anchor time that the vector store will expire.
-
-
expires_at: optional numberThe Unix timestamp (in seconds) for when the vector store will expire.
-
Example
curl https://api.openai.com/v1/vector_stores/$VECTOR_STORE_ID \
-H 'Content-Type: application/json' \
-H 'OpenAI-Beta: assistants=v2' \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{}'
Response
{
"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
}
Example
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"
}'
Response
{
"id": "vs_abc123",
"object": "vector_store",
"created_at": 1699061776,
"name": "Support FAQ",
"description": "Contains commonly asked questions and answers, organized by topic.",
"bytes": 139920,
"file_counts": {
"in_progress": 0,
"completed": 3,
"failed": 0,
"cancelled": 0,
"total": 3
}
}
Delete vector store
delete /vector_stores/{vector_store_id}
Delete vector store
Path Parameters
vector_store_id: string
Returns
-
VectorStoreDeleted object { id, deleted, object }-
id: string -
deleted: boolean -
object: "vector_store.deleted""vector_store.deleted"
-
Example
curl https://api.openai.com/v1/vector_stores/$VECTOR_STORE_ID \
-X DELETE \
-H 'OpenAI-Beta: assistants=v2' \
-H "Authorization: Bearer $OPENAI_API_KEY"
Response
{
"id": "id",
"deleted": true,
"object": "vector_store.deleted"
}
Example
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
Response
{
id: "vs_abc123",
object: "vector_store.deleted",
deleted: true
}
Search vector store
post /vector_stores/{vector_store_id}/search
Search vector store
Path Parameters
vector_store_id: string
Body Parameters
-
query: string or array of stringA query string for a search
-
string -
array of string
-
-
filters: optional ComparisonFilter or CompoundFilterA filter to apply based on file attributes.
-
ComparisonFilter object { key, type, value }A filter used to compare a specified attribute key to a given value using a defined comparison operation.
-
key: stringThe key to compare against the value.
-
type: "eq" or "ne" or "gt" or 5 moreSpecifies the comparison operator:
eq,ne,gt,gte,lt,lte,in,nin.-
eq: equals -
ne: not equal -
gt: greater than -
gte: greater than or equal -
lt: less than -
lte: less than or equal -
in: in -
nin: not in -
"eq" -
"ne" -
"gt" -
"gte" -
"lt" -
"lte" -
"in" -
"nin"
-
-
value: string or number or boolean or array of string or numberThe value to compare against the attribute key; supports string, number, or boolean types.
-
string -
number -
boolean -
array of string or number-
string -
number
-
-
-
-
CompoundFilter object { filters, type }Combine multiple filters using
andoror.-
filters: array of ComparisonFilter or unknownArray of filters to combine. Items can be
ComparisonFilterorCompoundFilter.-
ComparisonFilter object { key, type, value }A filter used to compare a specified attribute key to a given value using a defined comparison operation.
-
unknown
-
-
type: "and" or "or"Type of operation:
andoror.-
"and" -
"or"
-
-
-
-
max_num_results: optional numberThe maximum number of results to return. This number should be between 1 and 50 inclusive.
-
ranking_options: optional object { ranker, score_threshold }Ranking options for search.
-
ranker: optional "none" or "auto" or "default-2024-11-15"Enable re-ranking; set to
noneto disable, which can help reduce latency.-
"none" -
"auto" -
"default-2024-11-15"
-
-
score_threshold: optional number
-
-
rewrite_query: optional booleanWhether to rewrite the natural language query for vector search.
Returns
-
data: array of object { attributes, content, file_id, 2 more }The list of search result items.
-
attributes: map[string or number or boolean]Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters, booleans, or numbers.
-
string -
number -
boolean
-
-
content: array of object { text, type }Content chunks from the file.
-
text: stringThe text content returned from search.
-
type: "text"The type of content.
"text"
-
-
file_id: stringThe ID of the vector store file.
-
filename: stringThe name of the vector store file.
-
score: numberThe similarity score for the result.
-
-
has_more: booleanIndicates if there are more results to fetch.
-
next_page: stringThe token for the next page, if any.
-
object: "vector_store.search_results.page"The object type, which is always
vector_store.search_results.page"vector_store.search_results.page"
-
search_query: array of string
Example
curl https://api.openai.com/v1/vector_stores/$VECTOR_STORE_ID/search \
-H 'Content-Type: application/json' \
-H 'OpenAI-Beta: assistants=v2' \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"query": "string"
}'
Response
{
"data": [
{
"attributes": {
"foo": "string"
},
"content": [
{
"text": "text",
"type": "text"
}
],
"file_id": "file_id",
"filename": "filename",
"score": 0
}
],
"has_more": true,
"next_page": "next_page",
"object": "vector_store.search_results.page",
"search_query": [
"string"
]
}
Example
curl -X POST \
https://api.openai.com/v1/vector_stores/vs_abc123/search \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "What is the return policy?", "filters": {...}}'
Response
{
"object": "vector_store.search_results.page",
"search_query": "What is the return policy?",
"data": [
{
"file_id": "file_123",
"filename": "document.pdf",
"score": 0.95,
"attributes": {
"author": "John Doe",
"date": "2023-01-01"
},
"content": [
{
"type": "text",
"text": "Relevant chunk"
}
]
},
{
"file_id": "file_456",
"filename": "notes.txt",
"score": 0.89,
"attributes": {
"author": "Jane Smith",
"date": "2023-01-02"
},
"content": [
{
"type": "text",
"text": "Sample text content from the vector store."
}
]
}
],
"has_more": false,
"next_page": null
}
Domain Types
Auto File Chunking Strategy Param
-
AutoFileChunkingStrategyParam object { type }The default strategy. This strategy currently uses a
max_chunk_size_tokensof800andchunk_overlap_tokensof400.-
type: "auto"Always
auto."auto"
-
File Chunking Strategy
-
FileChunkingStrategy = StaticFileChunkingStrategyObject or OtherFileChunkingStrategyObjectThe strategy used to chunk the file.
-
StaticFileChunkingStrategyObject object { static, type }-
static: StaticFileChunkingStrategy-
chunk_overlap_tokens: numberThe number of tokens that overlap between chunks. The default value is
400.Note that the overlap must not exceed half of
max_chunk_size_tokens. -
max_chunk_size_tokens: numberThe maximum number of tokens in each chunk. The default value is
800. The minimum value is100and the maximum value is4096.
-
-
type: "static"Always
static."static"
-
-
OtherFileChunkingStrategyObject object { type }This is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the
chunking_strategyconcept was introduced in the API.-
type: "other"Always
other."other"
-
-
File Chunking Strategy Param
-
FileChunkingStrategyParam = AutoFileChunkingStrategyParam or StaticFileChunkingStrategyObjectParamThe chunking strategy used to chunk the file(s). If not set, will use the
autostrategy. Only applicable iffile_idsis non-empty.-
AutoFileChunkingStrategyParam object { type }The default strategy. This strategy currently uses a
max_chunk_size_tokensof800andchunk_overlap_tokensof400.-
type: "auto"Always
auto."auto"
-
-
StaticFileChunkingStrategyObjectParam object { static, type }Customize your own chunking strategy by setting chunk size and chunk overlap.
-
static: StaticFileChunkingStrategy-
chunk_overlap_tokens: numberThe number of tokens that overlap between chunks. The default value is
400.Note that the overlap must not exceed half of
max_chunk_size_tokens. -
max_chunk_size_tokens: numberThe maximum number of tokens in each chunk. The default value is
800. The minimum value is100and the maximum value is4096.
-
-
type: "static"Always
static."static"
-
-
Other File Chunking Strategy Object
-
OtherFileChunkingStrategyObject object { type }This is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the
chunking_strategyconcept was introduced in the API.-
type: "other"Always
other."other"
-
Static File Chunking Strategy
-
StaticFileChunkingStrategy object { chunk_overlap_tokens, max_chunk_size_tokens }-
chunk_overlap_tokens: numberThe number of tokens that overlap between chunks. The default value is
400.Note that the overlap must not exceed half of
max_chunk_size_tokens. -
max_chunk_size_tokens: numberThe maximum number of tokens in each chunk. The default value is
800. The minimum value is100and the maximum value is4096.
-
Static File Chunking Strategy Object
-
StaticFileChunkingStrategyObject object { static, type }-
static: StaticFileChunkingStrategy-
chunk_overlap_tokens: numberThe number of tokens that overlap between chunks. The default value is
400.Note that the overlap must not exceed half of
max_chunk_size_tokens. -
max_chunk_size_tokens: numberThe maximum number of tokens in each chunk. The default value is
800. The minimum value is100and the maximum value is4096.
-
-
type: "static"Always
static."static"
-
Static File Chunking Strategy Object Param
-
StaticFileChunkingStrategyObjectParam object { static, type }Customize your own chunking strategy by setting chunk size and chunk overlap.
-
static: StaticFileChunkingStrategy-
chunk_overlap_tokens: numberThe number of tokens that overlap between chunks. The default value is
400.Note that the overlap must not exceed half of
max_chunk_size_tokens. -
max_chunk_size_tokens: numberThe maximum number of tokens in each chunk. The default value is
800. The minimum value is100and the maximum value is4096.
-
-
type: "static"Always
static."static"
-
Vector Store
-
VectorStore object { id, created_at, file_counts, 8 more }A vector store is a collection of processed files can be used by the
file_searchtool.-
id: stringThe identifier, which can be referenced in API endpoints.
-
created_at: numberThe Unix timestamp (in seconds) for when the vector store was created.
-
file_counts: object { cancelled, completed, failed, 2 more }-
cancelled: numberThe number of files that were cancelled.
-
completed: numberThe number of files that have been successfully processed.
-
failed: numberThe number of files that have failed to process.
-
in_progress: numberThe number of files that are currently being processed.
-
total: numberThe total number of files.
-
-
last_active_at: numberThe Unix timestamp (in seconds) for when the vector store was last active.
-
metadata: MetadataSet of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard.
Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.
-
name: stringThe name of the vector store.
-
object: "vector_store"The object type, which is always
vector_store."vector_store"
-
status: "expired" or "in_progress" or "completed"The status of the vector store, which can be either
expired,in_progress, orcompleted. A status ofcompletedindicates that the vector store is ready for use.-
"expired" -
"in_progress" -
"completed"
-
-
usage_bytes: numberThe total number of bytes used by the files in the vector store.
-
expires_after: optional object { anchor, days }The expiration policy for a vector store.
-
anchor: "last_active_at"Anchor timestamp after which the expiration policy applies. Supported anchors:
last_active_at."last_active_at"
-
days: numberThe number of days after the anchor time that the vector store will expire.
-
-
expires_at: optional numberThe Unix timestamp (in seconds) for when the vector store will expire.
-
Vector Store Deleted
-
VectorStoreDeleted object { id, deleted, object }-
id: string -
deleted: boolean -
object: "vector_store.deleted""vector_store.deleted"
-
Vector Store Search Response
-
VectorStoreSearchResponse object { attributes, content, file_id, 2 more }-
attributes: map[string or number or boolean]Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters, booleans, or numbers.
-
string -
number -
boolean
-
-
content: array of object { text, type }Content chunks from the file.
-
text: stringThe text content returned from search.
-
type: "text"The type of content.
"text"
-
-
file_id: stringThe ID of the vector store file.
-
filename: stringThe name of the vector store file.
-
score: numberThe similarity score for the result.
-
Files
List vector store files
get /vector_stores/{vector_store_id}/files
List vector store files
Path Parameters
vector_store_id: string
Query Parameters
-
after: optional stringA cursor for use in pagination.
afteris an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. -
before: optional stringA cursor for use in pagination.
beforeis an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. -
filter: optional "in_progress" or "completed" or "failed" or "cancelled"Filter by file status. One of
in_progress,completed,failed,cancelled.-
"in_progress" -
"completed" -
"failed" -
"cancelled"
-
-
limit: optional numberA limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
-
order: optional "asc" or "desc"Sort order by the
created_attimestamp of the objects.ascfor ascending order anddescfor descending order.-
"asc" -
"desc"
-
Returns
-
data: array of VectorStoreFile-
id: stringThe identifier, which can be referenced in API endpoints.
-
created_at: numberThe Unix timestamp (in seconds) for when the vector store file was created.
-
last_error: object { code, message }The last error associated with this vector store file. Will be
nullif there are no errors.-
code: "server_error" or "unsupported_file" or "invalid_file"One of
server_error,unsupported_file, orinvalid_file.-
"server_error" -
"unsupported_file" -
"invalid_file"
-
-
message: stringA human-readable description of the error.
-
-
object: "vector_store.file"The object type, which is always
vector_store.file."vector_store.file"
-
status: "in_progress" or "completed" or "cancelled" or "failed"The status of the vector store file, which can be either
in_progress,completed,cancelled, orfailed. The statuscompletedindicates that the vector store file is ready for use.-
"in_progress" -
"completed" -
"cancelled" -
"failed"
-
-
usage_bytes: numberThe total vector store usage in bytes. Note that this may be different from the original file size.
-
vector_store_id: stringThe ID of the vector store that the File is attached to.
-
attributes: optional map[string or number or boolean]Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters, booleans, or numbers.
-
string -
number -
boolean
-
-
chunking_strategy: optional FileChunkingStrategyThe strategy used to chunk the file.
-
StaticFileChunkingStrategyObject object { static, type }-
static: StaticFileChunkingStrategy-
chunk_overlap_tokens: numberThe number of tokens that overlap between chunks. The default value is
400.Note that the overlap must not exceed half of
max_chunk_size_tokens. -
max_chunk_size_tokens: numberThe maximum number of tokens in each chunk. The default value is
800. The minimum value is100and the maximum value is4096.
-
-
type: "static"Always
static."static"
-
-
OtherFileChunkingStrategyObject object { type }This is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the
chunking_strategyconcept was introduced in the API.-
type: "other"Always
other."other"
-
-
-
-
first_id: string -
has_more: boolean -
last_id: string -
object: string
Example
curl https://api.openai.com/v1/vector_stores/$VECTOR_STORE_ID/files \
-H 'OpenAI-Beta: assistants=v2' \
-H "Authorization: Bearer $OPENAI_API_KEY"
Response
{
"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"
}
Example
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"
Response
{
"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
}
Create vector store file
post /vector_stores/{vector_store_id}/files
Create vector store file
Path Parameters
vector_store_id: string
Body Parameters
-
file_id: stringA File ID that the vector store should use. Useful for tools like
file_searchthat can access files. For multi-file ingestion, we recommendfile_batchesto minimize per-vector-store write requests. -
attributes: optional map[string or number or boolean]Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters, booleans, or numbers.
-
string -
number -
boolean
-
-
chunking_strategy: optional FileChunkingStrategyParamThe chunking strategy used to chunk the file(s). If not set, will use the
autostrategy. Only applicable iffile_idsis non-empty.-
AutoFileChunkingStrategyParam object { type }The default strategy. This strategy currently uses a
max_chunk_size_tokensof800andchunk_overlap_tokensof400.-
type: "auto"Always
auto."auto"
-
-
StaticFileChunkingStrategyObjectParam object { static, type }Customize your own chunking strategy by setting chunk size and chunk overlap.
-
static: StaticFileChunkingStrategy-
chunk_overlap_tokens: numberThe number of tokens that overlap between chunks. The default value is
400.Note that the overlap must not exceed half of
max_chunk_size_tokens. -
max_chunk_size_tokens: numberThe maximum number of tokens in each chunk. The default value is
800. The minimum value is100and the maximum value is4096.
-
-
type: "static"Always
static."static"
-
-
Returns
-
VectorStoreFile object { id, created_at, last_error, 6 more }A list of files attached to a vector store.
-
id: stringThe identifier, which can be referenced in API endpoints.
-
created_at: numberThe Unix timestamp (in seconds) for when the vector store file was created.
-
last_error: object { code, message }The last error associated with this vector store file. Will be
nullif there are no errors.-
code: "server_error" or "unsupported_file" or "invalid_file"One of
server_error,unsupported_file, orinvalid_file.-
"server_error" -
"unsupported_file" -
"invalid_file"
-
-
message: stringA human-readable description of the error.
-
-
object: "vector_store.file"The object type, which is always
vector_store.file."vector_store.file"
-
status: "in_progress" or "completed" or "cancelled" or "failed"The status of the vector store file, which can be either
in_progress,completed,cancelled, orfailed. The statuscompletedindicates that the vector store file is ready for use.-
"in_progress" -
"completed" -
"cancelled" -
"failed"
-
-
usage_bytes: numberThe total vector store usage in bytes. Note that this may be different from the original file size.
-
vector_store_id: stringThe ID of the vector store that the File is attached to.
-
attributes: optional map[string or number or boolean]Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters, booleans, or numbers.
-
string -
number -
boolean
-
-
chunking_strategy: optional FileChunkingStrategyThe strategy used to chunk the file.
-
StaticFileChunkingStrategyObject object { static, type }-
static: StaticFileChunkingStrategy-
chunk_overlap_tokens: numberThe number of tokens that overlap between chunks. The default value is
400.Note that the overlap must not exceed half of
max_chunk_size_tokens. -
max_chunk_size_tokens: numberThe maximum number of tokens in each chunk. The default value is
800. The minimum value is100and the maximum value is4096.
-
-
type: "static"Always
static."static"
-
-
OtherFileChunkingStrategyObject object { type }This is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the
chunking_strategyconcept was introduced in the API.-
type: "other"Always
other."other"
-
-
-
Example
curl https://api.openai.com/v1/vector_stores/$VECTOR_STORE_ID/files \
-H 'Content-Type: application/json' \
-H 'OpenAI-Beta: assistants=v2' \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"file_id": "file_id"
}'
Response
{
"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"
}
}
Example
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"
}'
Response
{
"id": "file-abc123",
"object": "vector_store.file",
"created_at": 1699061776,
"usage_bytes": 1234,
"vector_store_id": "vs_abcd",
"status": "completed",
"last_error": null
}
Update vector store file attributes
post /vector_stores/{vector_store_id}/files/{file_id}
Update vector store file attributes
Path Parameters
-
vector_store_id: string -
file_id: string
Body Parameters
-
attributes: map[string or number or boolean]Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters, booleans, or numbers.
-
string -
number -
boolean
-
Returns
-
VectorStoreFile object { id, created_at, last_error, 6 more }A list of files attached to a vector store.
-
id: stringThe identifier, which can be referenced in API endpoints.
-
created_at: numberThe Unix timestamp (in seconds) for when the vector store file was created.
-
last_error: object { code, message }The last error associated with this vector store file. Will be
nullif there are no errors.-
code: "server_error" or "unsupported_file" or "invalid_file"One of
server_error,unsupported_file, orinvalid_file.-
"server_error" -
"unsupported_file" -
"invalid_file"
-
-
message: stringA human-readable description of the error.
-
-
object: "vector_store.file"The object type, which is always
vector_store.file."vector_store.file"
-
status: "in_progress" or "completed" or "cancelled" or "failed"The status of the vector store file, which can be either
in_progress,completed,cancelled, orfailed. The statuscompletedindicates that the vector store file is ready for use.-
"in_progress" -
"completed" -
"cancelled" -
"failed"
-
-
usage_bytes: numberThe total vector store usage in bytes. Note that this may be different from the original file size.
-
vector_store_id: stringThe ID of the vector store that the File is attached to.
-
attributes: optional map[string or number or boolean]Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters, booleans, or numbers.
-
string -
number -
boolean
-
-
chunking_strategy: optional FileChunkingStrategyThe strategy used to chunk the file.
-
StaticFileChunkingStrategyObject object { static, type }-
static: StaticFileChunkingStrategy-
chunk_overlap_tokens: numberThe number of tokens that overlap between chunks. The default value is
400.Note that the overlap must not exceed half of
max_chunk_size_tokens. -
max_chunk_size_tokens: numberThe maximum number of tokens in each chunk. The default value is
800. The minimum value is100and the maximum value is4096.
-
-
type: "static"Always
static."static"
-
-
OtherFileChunkingStrategyObject object { type }This is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the
chunking_strategyconcept was introduced in the API.-
type: "other"Always
other."other"
-
-
-
Example
curl https://api.openai.com/v1/vector_stores/$VECTOR_STORE_ID/files/$FILE_ID \
-H 'Content-Type: application/json' \
-H 'OpenAI-Beta: assistants=v2' \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"attributes": {
"foo": "string"
}
}'
Response
{
"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"
}
}
Example
curl https://api.openai.com/v1/vector_stores/{vector_store_id}/files/{file_id} \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"attributes": {"key1": "value1", "key2": 2}}'
Response
{
"id": "file-abc123",
"object": "vector_store.file",
"usage_bytes": 1234,
"created_at": 1699061776,
"vector_store_id": "vs_abcd",
"status": "completed",
"last_error": null,
"chunking_strategy": {...},
"attributes": {"key1": "value1", "key2": 2}
}
Retrieve vector store file
get /vector_stores/{vector_store_id}/files/{file_id}
Retrieve vector store file
Path Parameters
-
vector_store_id: string -
file_id: string
Returns
-
VectorStoreFile object { id, created_at, last_error, 6 more }A list of files attached to a vector store.
-
id: stringThe identifier, which can be referenced in API endpoints.
-
created_at: numberThe Unix timestamp (in seconds) for when the vector store file was created.
-
last_error: object { code, message }The last error associated with this vector store file. Will be
nullif there are no errors.-
code: "server_error" or "unsupported_file" or "invalid_file"One of
server_error,unsupported_file, orinvalid_file.-
"server_error" -
"unsupported_file" -
"invalid_file"
-
-
message: stringA human-readable description of the error.
-
-
object: "vector_store.file"The object type, which is always
vector_store.file."vector_store.file"
-
status: "in_progress" or "completed" or "cancelled" or "failed"The status of the vector store file, which can be either
in_progress,completed,cancelled, orfailed. The statuscompletedindicates that the vector store file is ready for use.-
"in_progress" -
"completed" -
"cancelled" -
"failed"
-
-
usage_bytes: numberThe total vector store usage in bytes. Note that this may be different from the original file size.
-
vector_store_id: stringThe ID of the vector store that the File is attached to.
-
attributes: optional map[string or number or boolean]Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters, booleans, or numbers.
-
string -
number -
boolean
-
-
chunking_strategy: optional FileChunkingStrategyThe strategy used to chunk the file.
-
StaticFileChunkingStrategyObject object { static, type }-
static: StaticFileChunkingStrategy-
chunk_overlap_tokens: numberThe number of tokens that overlap between chunks. The default value is
400.Note that the overlap must not exceed half of
max_chunk_size_tokens. -
max_chunk_size_tokens: numberThe maximum number of tokens in each chunk. The default value is
800. The minimum value is100and the maximum value is4096.
-
-
type: "static"Always
static."static"
-
-
OtherFileChunkingStrategyObject object { type }This is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the
chunking_strategyconcept was introduced in the API.-
type: "other"Always
other."other"
-
-
-
Example
curl https://api.openai.com/v1/vector_stores/$VECTOR_STORE_ID/files/$FILE_ID \
-H 'OpenAI-Beta: assistants=v2' \
-H "Authorization: Bearer $OPENAI_API_KEY"
Response
{
"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"
}
}
Example
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"
Response
{
"id": "file-abc123",
"object": "vector_store.file",
"created_at": 1699061776,
"vector_store_id": "vs_abcd",
"status": "completed",
"last_error": null
}
Delete vector store file
delete /vector_stores/{vector_store_id}/files/{file_id}
Delete vector store file
Path Parameters
-
vector_store_id: string -
file_id: string
Returns
-
VectorStoreFileDeleted object { id, deleted, object }-
id: string -
deleted: boolean -
object: "vector_store.file.deleted""vector_store.file.deleted"
-
Example
curl https://api.openai.com/v1/vector_stores/$VECTOR_STORE_ID/files/$FILE_ID \
-X DELETE \
-H 'OpenAI-Beta: assistants=v2' \
-H "Authorization: Bearer $OPENAI_API_KEY"
Response
{
"id": "id",
"deleted": true,
"object": "vector_store.file.deleted"
}
Example
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
Response
{
id: "file-abc123",
object: "vector_store.file.deleted",
deleted: true
}
Retrieve vector store file content
get /vector_stores/{vector_store_id}/files/{file_id}/content
Retrieve vector store file content
Path Parameters
-
vector_store_id: string -
file_id: string
Returns
-
data: array of object { text, type }Parsed content of the file.
-
text: optional stringThe text content
-
type: optional stringThe content type (currently only
"text")
-
-
has_more: booleanIndicates if there are more content pages to fetch.
-
next_page: stringThe token for the next page, if any.
-
object: "vector_store.file_content.page"The object type, which is always
vector_store.file_content.page"vector_store.file_content.page"
Example
curl https://api.openai.com/v1/vector_stores/$VECTOR_STORE_ID/files/$FILE_ID/content \
-H 'OpenAI-Beta: assistants=v2' \
-H "Authorization: Bearer $OPENAI_API_KEY"
Response
{
"data": [
{
"text": "text",
"type": "type"
}
],
"has_more": true,
"next_page": "next_page",
"object": "vector_store.file_content.page"
}
Example
curl \
https://api.openai.com/v1/vector_stores/vs_abc123/files/file-abc123/content \
-H "Authorization: Bearer $OPENAI_API_KEY"
Response
{
"file_id": "file-abc123",
"filename": "example.txt",
"attributes": {"key": "value"},
"content": [
{"type": "text", "text": "..."},
...
]
}
Domain Types
Vector Store File
-
VectorStoreFile object { id, created_at, last_error, 6 more }A list of files attached to a vector store.
-
id: stringThe identifier, which can be referenced in API endpoints.
-
created_at: numberThe Unix timestamp (in seconds) for when the vector store file was created.
-
last_error: object { code, message }The last error associated with this vector store file. Will be
nullif there are no errors.-
code: "server_error" or "unsupported_file" or "invalid_file"One of
server_error,unsupported_file, orinvalid_file.-
"server_error" -
"unsupported_file" -
"invalid_file"
-
-
message: stringA human-readable description of the error.
-
-
object: "vector_store.file"The object type, which is always
vector_store.file."vector_store.file"
-
status: "in_progress" or "completed" or "cancelled" or "failed"The status of the vector store file, which can be either
in_progress,completed,cancelled, orfailed. The statuscompletedindicates that the vector store file is ready for use.-
"in_progress" -
"completed" -
"cancelled" -
"failed"
-
-
usage_bytes: numberThe total vector store usage in bytes. Note that this may be different from the original file size.
-
vector_store_id: stringThe ID of the vector store that the File is attached to.
-
attributes: optional map[string or number or boolean]Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters, booleans, or numbers.
-
string -
number -
boolean
-
-
chunking_strategy: optional FileChunkingStrategyThe strategy used to chunk the file.
-
StaticFileChunkingStrategyObject object { static, type }-
static: StaticFileChunkingStrategy-
chunk_overlap_tokens: numberThe number of tokens that overlap between chunks. The default value is
400.Note that the overlap must not exceed half of
max_chunk_size_tokens. -
max_chunk_size_tokens: numberThe maximum number of tokens in each chunk. The default value is
800. The minimum value is100and the maximum value is4096.
-
-
type: "static"Always
static."static"
-
-
OtherFileChunkingStrategyObject object { type }This is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the
chunking_strategyconcept was introduced in the API.-
type: "other"Always
other."other"
-
-
-
Vector Store File Deleted
-
VectorStoreFileDeleted object { id, deleted, object }-
id: string -
deleted: boolean -
object: "vector_store.file.deleted""vector_store.file.deleted"
-
File Content Response
-
FileContentResponse object { text, type }-
text: optional stringThe text content
-
type: optional stringThe content type (currently only
"text")
-
File Batches
Create vector store file batch
post /vector_stores/{vector_store_id}/file_batches
Create vector store file batch
Path Parameters
vector_store_id: string
Body Parameters
-
attributes: optional map[string or number or boolean]Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters, booleans, or numbers.
-
string -
number -
boolean
-
-
chunking_strategy: optional FileChunkingStrategyParamThe chunking strategy used to chunk the file(s). If not set, will use the
autostrategy. Only applicable iffile_idsis non-empty.-
AutoFileChunkingStrategyParam object { type }The default strategy. This strategy currently uses a
max_chunk_size_tokensof800andchunk_overlap_tokensof400.-
type: "auto"Always
auto."auto"
-
-
StaticFileChunkingStrategyObjectParam object { static, type }Customize your own chunking strategy by setting chunk size and chunk overlap.
-
static: StaticFileChunkingStrategy-
chunk_overlap_tokens: numberThe number of tokens that overlap between chunks. The default value is
400.Note that the overlap must not exceed half of
max_chunk_size_tokens. -
max_chunk_size_tokens: numberThe maximum number of tokens in each chunk. The default value is
800. The minimum value is100and the maximum value is4096.
-
-
type: "static"Always
static."static"
-
-
-
file_ids: optional array of stringA list of File IDs that the vector store should use. Useful for tools like
file_searchthat can access files. Ifattributesorchunking_strategyare provided, they will be applied to all files in the batch. The maximum batch size is 2000 files. This endpoint is recommended for multi-file ingestion and helps reduce per-vector-store write request pressure. Mutually exclusive withfiles. -
files: optional array of object { file_id, attributes, chunking_strategy }A list of objects that each include a
file_idplus optionalattributesorchunking_strategy. Use this when you need to override metadata for specific files. The globalattributesorchunking_strategywill be ignored and must be specified for each file. The maximum batch size is 2000 files. This endpoint is recommended for multi-file ingestion and helps reduce per-vector-store write request pressure. Mutually exclusive withfile_ids.-
file_id: stringA File ID that the vector store should use. Useful for tools like
file_searchthat can access files. For multi-file ingestion, we recommendfile_batchesto minimize per-vector-store write requests. -
attributes: optional map[string or number or boolean]Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters, booleans, or numbers.
-
string -
number -
boolean
-
-
chunking_strategy: optional FileChunkingStrategyParamThe chunking strategy used to chunk the file(s). If not set, will use the
autostrategy. Only applicable iffile_idsis non-empty.
-
Returns
-
VectorStoreFileBatch object { id, created_at, file_counts, 3 more }A batch of files attached to a vector store.
-
id: stringThe identifier, which can be referenced in API endpoints.
-
created_at: numberThe Unix timestamp (in seconds) for when the vector store files batch was created.
-
file_counts: object { cancelled, completed, failed, 2 more }-
cancelled: numberThe number of files that where cancelled.
-
completed: numberThe number of files that have been processed.
-
failed: numberThe number of files that have failed to process.
-
in_progress: numberThe number of files that are currently being processed.
-
total: numberThe total number of files.
-
-
object: "vector_store.files_batch"The object type, which is always
vector_store.file_batch."vector_store.files_batch"
-
status: "in_progress" or "completed" or "cancelled" or "failed"The status of the vector store files batch, which can be either
in_progress,completed,cancelledorfailed.-
"in_progress" -
"completed" -
"cancelled" -
"failed"
-
-
vector_store_id: stringThe ID of the vector store that the File is attached to.
-
Example
curl https://api.openai.com/v1/vector_stores/$VECTOR_STORE_ID/file_batches \
-H 'Content-Type: application/json' \
-H 'OpenAI-Beta: assistants=v2' \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{}'
Response
{
"id": "id",
"created_at": 0,
"file_counts": {
"cancelled": 0,
"completed": 0,
"failed": 0,
"in_progress": 0,
"total": 0
},
"object": "vector_store.files_batch",
"status": "in_progress",
"vector_store_id": "vector_store_id"
}
Example
curl https://api.openai.com/v1/vector_stores/vs_abc123/file_batches \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json \
-H "OpenAI-Beta: assistants=v2" \
-d '{
"files": [
{
"file_id": "file-abc123",
"attributes": {"category": "finance"}
},
{
"file_id": "file-abc456",
"chunking_strategy": {
"type": "static",
"max_chunk_size_tokens": 1200,
"chunk_overlap_tokens": 200
}
}
]
}'
Response
{
"id": "vsfb_abc123",
"object": "vector_store.file_batch",
"created_at": 1699061776,
"vector_store_id": "vs_abc123",
"status": "in_progress",
"file_counts": {
"in_progress": 1,
"completed": 1,
"failed": 0,
"cancelled": 0,
"total": 0,
}
}
Retrieve vector store file batch
get /vector_stores/{vector_store_id}/file_batches/{batch_id}
Retrieve vector store file batch
Path Parameters
-
vector_store_id: string -
batch_id: string
Returns
-
VectorStoreFileBatch object { id, created_at, file_counts, 3 more }A batch of files attached to a vector store.
-
id: stringThe identifier, which can be referenced in API endpoints.
-
created_at: numberThe Unix timestamp (in seconds) for when the vector store files batch was created.
-
file_counts: object { cancelled, completed, failed, 2 more }-
cancelled: numberThe number of files that where cancelled.
-
completed: numberThe number of files that have been processed.
-
failed: numberThe number of files that have failed to process.
-
in_progress: numberThe number of files that are currently being processed.
-
total: numberThe total number of files.
-
-
object: "vector_store.files_batch"The object type, which is always
vector_store.file_batch."vector_store.files_batch"
-
status: "in_progress" or "completed" or "cancelled" or "failed"The status of the vector store files batch, which can be either
in_progress,completed,cancelledorfailed.-
"in_progress" -
"completed" -
"cancelled" -
"failed"
-
-
vector_store_id: stringThe ID of the vector store that the File is attached to.
-
Example
curl https://api.openai.com/v1/vector_stores/$VECTOR_STORE_ID/file_batches/$BATCH_ID \
-H 'OpenAI-Beta: assistants=v2' \
-H "Authorization: Bearer $OPENAI_API_KEY"
Response
{
"id": "id",
"created_at": 0,
"file_counts": {
"cancelled": 0,
"completed": 0,
"failed": 0,
"in_progress": 0,
"total": 0
},
"object": "vector_store.files_batch",
"status": "in_progress",
"vector_store_id": "vector_store_id"
}
Example
curl https://api.openai.com/v1/vector_stores/vs_abc123/file_batches/vsfb_abc123 \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-H "OpenAI-Beta: assistants=v2"
Response
{
"id": "vsfb_abc123",
"object": "vector_store.file_batch",
"created_at": 1699061776,
"vector_store_id": "vs_abc123",
"status": "in_progress",
"file_counts": {
"in_progress": 1,
"completed": 1,
"failed": 0,
"cancelled": 0,
"total": 0,
}
}
Cancel vector store file batch
post /vector_stores/{vector_store_id}/file_batches/{batch_id}/cancel
Cancel vector store file batch
Path Parameters
-
vector_store_id: string -
batch_id: string
Returns
-
VectorStoreFileBatch object { id, created_at, file_counts, 3 more }A batch of files attached to a vector store.
-
id: stringThe identifier, which can be referenced in API endpoints.
-
created_at: numberThe Unix timestamp (in seconds) for when the vector store files batch was created.
-
file_counts: object { cancelled, completed, failed, 2 more }-
cancelled: numberThe number of files that where cancelled.
-
completed: numberThe number of files that have been processed.
-
failed: numberThe number of files that have failed to process.
-
in_progress: numberThe number of files that are currently being processed.
-
total: numberThe total number of files.
-
-
object: "vector_store.files_batch"The object type, which is always
vector_store.file_batch."vector_store.files_batch"
-
status: "in_progress" or "completed" or "cancelled" or "failed"The status of the vector store files batch, which can be either
in_progress,completed,cancelledorfailed.-
"in_progress" -
"completed" -
"cancelled" -
"failed"
-
-
vector_store_id: stringThe ID of the vector store that the File is attached to.
-
Example
curl https://api.openai.com/v1/vector_stores/$VECTOR_STORE_ID/file_batches/$BATCH_ID/cancel \
-X POST \
-H 'OpenAI-Beta: assistants=v2' \
-H "Authorization: Bearer $OPENAI_API_KEY"
Response
{
"id": "id",
"created_at": 0,
"file_counts": {
"cancelled": 0,
"completed": 0,
"failed": 0,
"in_progress": 0,
"total": 0
},
"object": "vector_store.files_batch",
"status": "in_progress",
"vector_store_id": "vector_store_id"
}
Example
curl https://api.openai.com/v1/vector_stores/vs_abc123/files_batches/vsfb_abc123/cancel \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-H "OpenAI-Beta: assistants=v2" \
-X POST
Response
{
"id": "vsfb_abc123",
"object": "vector_store.file_batch",
"created_at": 1699061776,
"vector_store_id": "vs_abc123",
"status": "in_progress",
"file_counts": {
"in_progress": 12,
"completed": 3,
"failed": 0,
"cancelled": 0,
"total": 15,
}
}
List vector store files in a batch
get /vector_stores/{vector_store_id}/file_batches/{batch_id}/files
List vector store files in a batch
Path Parameters
-
vector_store_id: string -
batch_id: string
Query Parameters
-
after: optional stringA cursor for use in pagination.
afteris an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. -
before: optional stringA cursor for use in pagination.
beforeis an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. -
filter: optional "in_progress" or "completed" or "failed" or "cancelled"Filter by file status. One of
in_progress,completed,failed,cancelled.-
"in_progress" -
"completed" -
"failed" -
"cancelled"
-
-
limit: optional numberA limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
-
order: optional "asc" or "desc"Sort order by the
created_attimestamp of the objects.ascfor ascending order anddescfor descending order.-
"asc" -
"desc"
-
Returns
-
data: array of VectorStoreFile-
id: stringThe identifier, which can be referenced in API endpoints.
-
created_at: numberThe Unix timestamp (in seconds) for when the vector store file was created.
-
last_error: object { code, message }The last error associated with this vector store file. Will be
nullif there are no errors.-
code: "server_error" or "unsupported_file" or "invalid_file"One of
server_error,unsupported_file, orinvalid_file.-
"server_error" -
"unsupported_file" -
"invalid_file"
-
-
message: stringA human-readable description of the error.
-
-
object: "vector_store.file"The object type, which is always
vector_store.file."vector_store.file"
-
status: "in_progress" or "completed" or "cancelled" or "failed"The status of the vector store file, which can be either
in_progress,completed,cancelled, orfailed. The statuscompletedindicates that the vector store file is ready for use.-
"in_progress" -
"completed" -
"cancelled" -
"failed"
-
-
usage_bytes: numberThe total vector store usage in bytes. Note that this may be different from the original file size.
-
vector_store_id: stringThe ID of the vector store that the File is attached to.
-
attributes: optional map[string or number or boolean]Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters, booleans, or numbers.
-
string -
number -
boolean
-
-
chunking_strategy: optional FileChunkingStrategyThe strategy used to chunk the file.
-
StaticFileChunkingStrategyObject object { static, type }-
static: StaticFileChunkingStrategy-
chunk_overlap_tokens: numberThe number of tokens that overlap between chunks. The default value is
400.Note that the overlap must not exceed half of
max_chunk_size_tokens. -
max_chunk_size_tokens: numberThe maximum number of tokens in each chunk. The default value is
800. The minimum value is100and the maximum value is4096.
-
-
type: "static"Always
static."static"
-
-
OtherFileChunkingStrategyObject object { type }This is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the
chunking_strategyconcept was introduced in the API.-
type: "other"Always
other."other"
-
-
-
-
first_id: string -
has_more: boolean -
last_id: string -
object: string
Example
curl https://api.openai.com/v1/vector_stores/$VECTOR_STORE_ID/file_batches/$BATCH_ID/files \
-H 'OpenAI-Beta: assistants=v2' \
-H "Authorization: Bearer $OPENAI_API_KEY"
Response
{
"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"
}
Example
curl https://api.openai.com/v1/vector_stores/vs_abc123/files_batches/vsfb_abc123/files \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-H "OpenAI-Beta: assistants=v2"
Response
{
"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
}
Domain Types
Vector Store File Batch
-
VectorStoreFileBatch object { id, created_at, file_counts, 3 more }A batch of files attached to a vector store.
-
id: stringThe identifier, which can be referenced in API endpoints.
-
created_at: numberThe Unix timestamp (in seconds) for when the vector store files batch was created.
-
file_counts: object { cancelled, completed, failed, 2 more }-
cancelled: numberThe number of files that where cancelled.
-
completed: numberThe number of files that have been processed.
-
failed: numberThe number of files that have failed to process.
-
in_progress: numberThe number of files that are currently being processed.
-
total: numberThe total number of files.
-
-
object: "vector_store.files_batch"The object type, which is always
vector_store.file_batch."vector_store.files_batch"
-
status: "in_progress" or "completed" or "cancelled" or "failed"The status of the vector store files batch, which can be either
in_progress,completed,cancelledorfailed.-
"in_progress" -
"completed" -
"cancelled" -
"failed"
-
-
vector_store_id: stringThe ID of the vector store that the File is attached to.
-