POST/vector_stores

Create a vector store

Creates a vector store to collect processed files for use with the file_search tool. Supply file_ids to add files at creation, and optionally set a name, description, expiration policy, chunking strategy, or metadata.

  • IdempotentThe SDK sends Idempotency-Key, so a retried request is only applied once.

6 body fields

Vector store configuration and, optionally, files to add. All fields are optional.

file_idsarray<string>optional
A list of [File](https://developers.openai.com/api/reference/resources/files) IDs that the vector store should use. Useful for tools like `file_search` that can access files.
namestringoptional
The name of the vector store.
descriptionstringoptional
A description for the vector store. Can be used to describe the vector store's purpose.
expires_afterobjectoptional
The expiration policy for a vector store.
chunking_strategyobjectoptional
The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy. Only applicable if `file_ids` is non-empty.
metadataobjectoptional
Optional key-value metadata for the vector store. Supports up to 16 key-value pairs, with keys up to 64 characters and string values.

4 status codes
200Returns the created vector store, including its ID, status, file counts, usage, and configuration.
idstringrequired
The identifier, which can be referenced in API endpoints.
objectstringrequired
The object type, which is always `vector_store`.
Allowed:vector_store
created_atintegerrequired
The Unix timestamp (in seconds) for when the vector store was created.
namestringrequired
The name of the vector store.
usage_bytesintegerrequired
The total number of bytes used by the files in the vector store.
file_countsobjectrequired
statusstringrequired
The status of the vector store, which can be either `expired`, `in_progress`, or `completed`. A status of `completed` indicates that the vector store is ready for use.
Allowed:expiredin_progresscompleted
expires_afterobjectoptional
The expiration policy for a vector store.
expires_atintegeroptional
The Unix timestamp (in seconds) for when the vector store will expire.
last_active_atintegerrequired
The Unix timestamp (in seconds) for when the vector store was last active.
metadataobjectrequired
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.
400Returned when the vector store input, referenced files, or chunking configuration is invalid.
errorobjectrequired
404Returned when a referenced input file was not found or is not accessible.
errorobjectrequired
429Returned when the request rate limit is exceeded.
errorobjectrequired

Error handling

A 400 is returned when the vector store input, files, or chunking configuration is invalid; a 404 is returned when a referenced file is not found or accessible. A 429 is returned when the request rate limit is exceeded. file_ids can contain at most 500 IDs; if expires_after is supplied, anchor must be last_active_at and days must be between 1 and 365.