Skip to content
For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to the page URL.
Primary navigation

Create vector store file

vector_stores.files.create(strvector_store_id, FileCreateParams**kwargs) -> VectorStoreFile
POST/vector_stores/{vector_store_id}/files

Create a vector store file by attaching a File to a vector store.

ParametersExpand Collapse
vector_store_id: str
file_id: str

A File ID that the vector store should use. Useful for tools like file_search that can access files. For multi-file ingestion, we recommend file_batches to minimize per-vector-store write requests.

attributes: Optional[Dict[str, Union[str, float, bool]]]

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.

chunking_strategy: Optional[FileChunkingStrategyParam]

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.

ReturnsExpand Collapse
class VectorStoreFile: …

A list of files attached to a vector store.

id: str

The identifier, which can be referenced in API endpoints.

created_at: int

The Unix timestamp (in seconds) for when the vector store file was created.

formatunixtime
last_error: Optional[LastError]

The last error associated with this vector store file. Will be null if there are no errors.

object: Literal["vector_store.file"]

The object type, which is always vector_store.file.

status: Literal["in_progress", "completed", "cancelled", "failed"]

The status of the vector store file, which can be either in_progress, completed, cancelled, or failed. The status completed indicates that the vector store file is ready for use.

usage_bytes: int

The total vector store usage in bytes. Note that this may be different from the original file size.

vector_store_id: str

The ID of the vector store that the File is attached to.

attributes: Optional[Dict[str, Union[str, float, bool]]]

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.

chunking_strategy: Optional[FileChunkingStrategy]

The strategy used to chunk the file.

Create vector store file

from openai import OpenAI
client = OpenAI()

vector_store_file = client.vector_stores.files.create(
  vector_store_id="vs_abc123",
  file_id="file-abc123"
)
print(vector_store_file)
{
  "id": "file-abc123",
  "object": "vector_store.file",
  "created_at": 1699061776,
  "usage_bytes": 1234,
  "vector_store_id": "vs_abcd",
  "status": "completed",
  "last_error": null
}
Returns Examples
{
  "id": "file-abc123",
  "object": "vector_store.file",
  "created_at": 1699061776,
  "usage_bytes": 1234,
  "vector_store_id": "vs_abcd",
  "status": "completed",
  "last_error": null
}