Skip to main content

vector_stores

Creates, updates, deletes, gets or lists a vector_stores resource.

Overview

Namevector_stores
TypeResource
Idopenai.vector_stores.vector_stores

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstringThe identifier, which can be referenced in API endpoints.
namestringThe name of the vector store.
created_atinteger (unixtime)The Unix timestamp (in seconds) for when the vector store was created.
expires_afterobjectThe expiration policy for a vector store. (title: Vector store expiration policy)
expires_atinteger (unixtime)The Unix timestamp (in seconds) for when the vector store will expire.
file_countsobject
last_active_atinteger (unixtime)The Unix timestamp (in seconds) for when the vector store was last active.
metadataobjectSet 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. (x-oaiTypeLabel: map)
objectstringThe object type, which is always vector_store. (vector_store)
statusstringThe 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. (expired, in_progress, completed)
usage_bytesintegerThe total number of bytes used by the files in the vector store.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectvector_store_idopenai-organization, openai-project
listselectlimit, order, after, before, openai-organization, openai-project
createinsertopenai-organization, openai-project
updateupdatevector_store_idopenai-organization, openai-project
deletedeletevector_store_idopenai-organization, openai-project
searchexecvector_store_id, queryopenai-organization, openai-project

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
vector_store_idstringThe ID of the vector store to search.
afterstringA cursor for use in pagination. after is 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.
beforestringA cursor for use in pagination. before is 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.
limitintegerA limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. Automatically applied from a SQL LIMIT clause - SELECT ... LIMIT 10 sends limit=10 on the wire. Setting it explicitly in a WHERE clause is not required.
openai-organizationstringOptionally scope the request to a specific organization (overrides the default associated with the API key). Addressable in SQL as openai_organization.
openai-projectstringOptionally scope the request to a specific project (overrides the default associated with the API key). Addressable in SQL as openai_project.
orderstringSort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.

SELECT examples

OK

SELECT
id,
name,
created_at,
expires_after,
expires_at,
file_counts,
last_active_at,
metadata,
object,
status,
usage_bytes
FROM openai.vector_stores.vector_stores
WHERE vector_store_id = '{{ vector_store_id }}' -- required
AND "openai-organization" = '{{ openai-organization }}'
AND "openai-project" = '{{ openai-project }}'
;

INSERT examples

No description available.

INSERT INTO openai.vector_stores.vector_stores (
file_ids,
name,
description,
expires_after,
chunking_strategy,
metadata,
"openai-organization",
"openai-project"
)
SELECT
'{{ file_ids }}',
'{{ name }}',
'{{ description }}',
'{{ expires_after }}',
'{{ chunking_strategy }}',
'{{ metadata }}',
'{{ openai-organization }}',
'{{ openai-project }}'
RETURNING
id,
name,
created_at,
expires_after,
expires_at,
file_counts,
last_active_at,
metadata,
object,
status,
usage_bytes
;

UPDATE examples

No description available.

UPDATE openai.vector_stores.vector_stores
SET
name = '{{ name }}',
expires_after = '{{ expires_after }}',
metadata = '{{ metadata }}'
WHERE
vector_store_id = '{{ vector_store_id }}' --required
AND "openai-organization" = '{{ openai-organization}}'
AND "openai-project" = '{{ openai-project}}'
RETURNING
id,
name,
created_at,
expires_after,
expires_at,
file_counts,
last_active_at,
metadata,
object,
status,
usage_bytes;

DELETE examples

No description available.

DELETE FROM openai.vector_stores.vector_stores
WHERE vector_store_id = '{{ vector_store_id }}' --required
AND "openai-organization" = '{{ openai-organization }}'
AND "openai-project" = '{{ openai-project }}'
;

Lifecycle Methods

OK

EXEC openai.vector_stores.vector_stores.search
@vector_store_id='{{ vector_store_id }}' --required,
@openai-organization='{{ openai-organization }}',
@openai-project='{{ openai-project }}'
@@json=
'{
"query": "{{ query }}",
"rewrite_query": {{ rewrite_query }},
"max_num_results": {{ max_num_results }},
"filters": "{{ filters }}",
"ranking_options": "{{ ranking_options }}"
}'
;