Install the Python client library:
pip install actian-vectorai-client.Create a basic collection
To create a collection, specify a name and vector dimension. VectorAI DB automatically creates a Hierarchical Navigable Small World (HNSW) index for efficient search. The default distance metric is cosine similarity, and VectorAI DB applies default HNSW parameters when none are specified. The following example creates a collection namedmy_collection that accepts 128-dimensional vectors.
Create a collection with custom HNSW parameters
Customize the distance metric and index configuration when creating a collection. The HNSW parameters control the speed and accuracy tradeoff:m: Number of bidirectional links per node. Higher values improve recall but increase memory usage.ef_construct: Quality of index construction. Higher values create better indexes but take longer to build.
Check collection existence
Before creating a collection, verify whether it already exists to avoid errors. Theexists() method returns True if the collection exists and False otherwise.
Get or create collection
Useget_or_create() to ensure a collection exists before your application starts working with it. This method returns the existing collection if one is already present, or creates a new one with the specified parameters.
Vector dimension and distance metric are fixed after collection creation and cannot be changed. To use different values, you must delete and recreate the collection. HNSW parameters and optimizer settings can be updated after creation.