Vector Stores API
Create and manage vector stores, along with their files and file batches, that power the Responses file_search tool. Upload files via the Files API first. OpenAI only.
Objects
UniLM.VectorStoreObject — Type
VectorStoreObjectA vector store from the Vector Stores API: id, name, status, and file_counts; raw holds the unparsed JSON response.
UniLM.VectorStoreFileObject — Type
VectorStoreFileObjectA file attached to a vector store: id and status; raw holds the unparsed JSON response.
UniLM.VectorStoreFileBatch — Type
VectorStoreFileBatchA batch of files added to a vector store: id, status, and file_counts; raw holds the unparsed JSON response.
UniLM.VectorStoreList — Type
VectorStoreListA page of VectorStoreObjects from list_vector_stores; has_more signals that further pages are available.
Result Types
UniLM.VectorStoreSuccess — Type
Successful create/retrieve result wrapping a VectorStoreObject.
UniLM.VectorStoreListSuccess — Type
Successful list_vector_stores result wrapping a VectorStoreList.
UniLM.VectorStoreFileSuccess — Type
Successful add_vector_store_file result wrapping a VectorStoreFileObject.
UniLM.VectorStoreBatchSuccess — Type
Successful file-batch result wrapping a VectorStoreFileBatch.
UniLM.VectorStoreDeleteSuccess — Type
Successful delete_vector_store result; deleted confirms removal of id.
UniLM.VectorStoreFailure — Type
Vector Stores API error result: HTTP status and the raw response body.
UniLM.VectorStoreCallError — Type
Local/transport error from a Vector Stores API call (the request never completed).
Request Functions
UniLM.create_vector_store — Function
create_vector_store(; name=nothing, file_ids=nothing, expires_after=nothing,
chunking_strategy=nothing, metadata=nothing, service=OPENAIServiceEndpoint)Create a vector store. Returns VectorStoreSuccess, VectorStoreFailure, or VectorStoreCallError.
Pass config::Union{Nothing,RequestConfig} to override the timeout budget for this call (a single bounded attempt; max_attempts does not apply).
UniLM.retrieve_vector_store — Function
retrieve_vector_store(id; service=OPENAIServiceEndpoint)Pass config::Union{Nothing,RequestConfig} to override the timeout budget for this call (a single bounded attempt; max_attempts does not apply).
UniLM.list_vector_stores — Function
list_vector_stores(; limit=nothing, after=nothing, service=OPENAIServiceEndpoint)Pass config::Union{Nothing,RequestConfig} to override the timeout budget for this call (a single bounded attempt; max_attempts does not apply).
UniLM.delete_vector_store — Function
delete_vector_store(id; service=OPENAIServiceEndpoint)Pass config::Union{Nothing,RequestConfig} to override the timeout budget for this call (a single bounded attempt; max_attempts does not apply).
UniLM.add_vector_store_file — Function
add_vector_store_file(vector_store_id, file_id; chunking_strategy=nothing, service=OPENAIServiceEndpoint)Pass config::Union{Nothing,RequestConfig} to override the timeout budget for this call (a single bounded attempt; max_attempts does not apply).
UniLM.create_file_batch — Function
create_file_batch(vector_store_id, file_ids; chunking_strategy=nothing, service=OPENAIServiceEndpoint)Pass config::Union{Nothing,RequestConfig} to override the timeout budget for this call (a single bounded attempt; max_attempts does not apply).
UniLM.retrieve_file_batch — Function
retrieve_file_batch(vector_store_id, batch_id; service=OPENAIServiceEndpoint)Pass config::Union{Nothing,RequestConfig} to override the timeout budget for this call (a single bounded attempt; max_attempts does not apply).
UniLM.poll_file_batch — Function
poll_file_batch(vector_store_id, batch_id; interval=2.0, timeout=300.0, service=OPENAIServiceEndpoint)Poll a file batch until it reaches a terminal status (completed/failed/cancelled) or the timeout elapses. Returns the terminal VectorStoreBatchSuccess, or a VectorStoreCallError on timeout.
Pass config::Union{Nothing,RequestConfig} to override the timeout budget for this call (a single bounded attempt; max_attempts does not apply).
Accessors
UniLM.vector_store_id — Function
vector_store_id(v::VectorStoreObject) -> StringReturn the id of a VectorStoreObject, for use in file and batch calls.
Usage
# Create a vector store, then add files already uploaded via the Files API
store = create_vector_store(name="docs")
store isa VectorStoreSuccess && println("Created: ", vector_store_id(store.response))
vs = vector_store_id(store.response)
# Add a single file, or a batch, then poll the batch to a terminal status
add_vector_store_file(vs, "file-abc123")
batch = create_file_batch(vs, ["file-abc123", "file-def456"])
batch isa VectorStoreBatchSuccess && poll_file_batch(vs, batch.response.id)
# List, retrieve, delete
stores = list_vector_stores(limit=10)
retrieve_vector_store(vs)
delete_vector_store(vs)