> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vectoraidb.actian.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Create a collection, insert vectors, and run your first similarity search.

Before starting, make sure VectorAI DB is running and your SDK is installed. See the [Docker setup guide](https://docs.vectoraidb.actian.com/home/installation/instructions.md) if you haven't done that yet.

> [tab] Python
>
> ## Prerequisites
>
> To use the Python SDK, make sure you have:
>
> * Python 3.10 or later
> * numpy 1.26 or later
> * grpcio 1.80 or later
> * pydantic 2.10 or later
>
> ## Step 1: Create a collection
>
> Connect to VectorAI DB and create a collection named `products` with dimension 128 and cosine distance metric.
>
> > [tab] Synchronous
> >
> > ```python theme={null}
> > from actian_vectorai import VectorAIClient, VectorParams, Distance
> >
> > with VectorAIClient("localhost:6574") as client:
> >     info = client.health_check()
> >     print(f"Connected to {info['title']} v{info['version']}")
> >
> >     client.collections.create(
> >         "products",
> >         vectors_config=VectorParams(size=128, distance=Distance.Cosine)
> >     )
> >     print("Collection 'products' created successfully")
> > ```
>
> > [tab] Asynchronous
> >
> > ```python theme={null}
> > import asyncio
> > from actian_vectorai import AsyncVectorAIClient, VectorParams, Distance
> >
> > async def main():
> >     async with AsyncVectorAIClient("localhost:6574") as client:
> >         info = await client.health_check()
> >         print(f"Connected to {info['title']} v{info['version']}")
> >
> >         await client.collections.create(
> >             "products",
> >             vectors_config=VectorParams(size=128, distance=Distance.Cosine)
> >         )
> >         print("Collection 'products' created successfully")
> >
> > asyncio.run(main())
> > ```
>
> ## Step 2: Insert vectors
>
> ```python theme={null}
> import random
> from typing import List
> from actian_vectorai import VectorAIClient, PointStruct
>
> NUM_VECTORS = 100
> DIMENSION = 128
>
> def generate_sample_products(
>     num_products: int = 100,
>     dimension: int = 128,
>     base_price: float = 10.0,
>     price_variance: float = 100.0,
>     seed: int = None
> ) -> List[PointStruct]:
>     if seed is not None:
>         random.seed(seed)
>
>     categories = ["electronics", "clothing", "food"]
>     points = []
>
>     for i in range(num_products):
>         category = categories[i % 3]
>         price = float(i * base_price + random.random() * price_variance)
>         in_stock = (i % 2 == 0)
>
>         points.append(
>             PointStruct(
>                 id=i,
>                 vector=[random.gauss(0, 1) for _ in range(dimension)],
>                 payload={
>                     "id": i,
>                     "category": category,
>                     "price": round(price, 2),
>                     "in_stock": in_stock,
>                 }
>             )
>         )
>
>     return points
>
> with VectorAIClient("localhost:6574") as client:
>     print(f"Inserting {NUM_VECTORS} vectors...")
>
>     points = generate_sample_products(NUM_VECTORS, DIMENSION, seed=42)
>
>     client.points.upsert("products", points)
>     print(f"Inserted {NUM_VECTORS} vectors")
>
>     count = client.points.count("products")
>     print(f"Vector count: {count}")
> ```
>
> ## Step 3: Search for similar vectors
>
> ```python theme={null}
> from actian_vectorai import VectorAIClient
> import random
>
> DIMENSION = 128
> COLLECTION = "products"
>
> with VectorAIClient("localhost:6574") as client:
>     print("Searching for similar vectors...")
>     query = [random.gauss(0, 1) for _ in range(DIMENSION)]
>     results = client.points.search(COLLECTION, vector=query, limit=5)
>
>     print(f"Found {len(results)} results:")
>     for i, result in enumerate(results):
>         print(f"[{i+1}] ID: {result.id}, Score: {result.score:.4f}")
>
>     print("\nRetrieving vector details...")
>     retrieved = client.points.get(COLLECTION, ids=[results[0].id])
>     print(f"Top result payload: {retrieved[0].payload}")
> ```
>
> The following output is an example. Your scores will vary.
>
> ```
> Searching for similar vectors...
> Found 5 results:
> [1] ID: 39, Score: 29.2119
> [2] ID: 54, Score: 27.3639
> [3] ID: 76, Score: 23.6023
> [4] ID: 31, Score: 21.2087
> [5] ID: 22, Score: 17.9858
>
> Retrieving vector details...
> Top result payload: {'price': 451.6, 'id': 39, 'in_stock': False, 'category': 'electronics'}
> ```
>
> ## Step 4: Delete collection
>
> ```python theme={null}
> from actian_vectorai import VectorAIClient
>
> with VectorAIClient("localhost:6574") as client:
>     client.collections.delete("products")
>     print("Collection 'products' deleted successfully")
> ```

> [tab] JavaScript
>
> ## Prerequisites
>
> To use the JavaScript SDK, make sure you have:
>
> * Node.js 18 or later
> * npm 9 or later
>
> ## Step 1: Create a collection
>
> Connect to VectorAI DB and create a collection named `products` with dimension 128 and cosine distance metric. Save each step below to a single file called `quickstart.ts` and run it with `npx tsx quickstart.ts`.
>
> ```typescript theme={null}
> import { VectorAIClient } from '@actian/vectorai-client';
>
> const DIMENSION = 128;
> const COLLECTION = 'products';
>
> const client = new VectorAIClient('localhost:6574');
>
> const info = await client.healthCheck();
> console.log(`Connected to ${info.title} v${info.version}`);
>
> await client.collections.create(COLLECTION, {
>     dimension: DIMENSION,
>     distanceMetric: 'COSINE',
> });
> console.log(`Collection '${COLLECTION}' created successfully`);
> ```
>
> ## Step 2: Generate sample data
>
> Create a helper function to generate sample product vectors with metadata.
>
> ```typescript theme={null}
> function generateSampleProducts(numProducts: number, dimension: number) {
>     const categories = ['electronics', 'clothing', 'food'];
>     return Array.from({ length: numProducts }, (_, i) => ({
>         id: i,
>         vector: Array.from({ length: dimension }, () => Math.random() * 2 - 1),
>         payload: {
>             id: i,
>             category: categories[i % 3],
>             price: parseFloat((i * 10 + Math.random() * 100).toFixed(2)),
>             in_stock: i % 2 === 0,
>         },
>     }));
> }
> ```
>
> ## Step 3: Insert vectors
>
> ```typescript theme={null}
> const NUM_VECTORS = 100;
>
> console.log(`Inserting ${NUM_VECTORS} vectors...`);
> const points = generateSampleProducts(NUM_VECTORS, DIMENSION);
>
> await client.points.upsert(COLLECTION, points, { wait: true });
> console.log(`Inserted ${NUM_VECTORS} vectors`);
>
> const count = await client.points.count(COLLECTION);
> console.log(`Vector count: ${count}`);
> ```
>
> ## Step 4: Search for similar vectors
>
> ```typescript theme={null}
> console.log('\nSearching for similar vectors...');
> const query = Array.from({ length: DIMENSION }, () => Math.random() * 2 - 1);
> const results = await client.points.search(COLLECTION, query, { limit: 5 });
>
> console.log(`Found ${results.length} results:`);
> for (const [i, result] of results.entries()) {
>     console.log(`[${i + 1}] ID: ${result.id}, Score: ${result.score.toFixed(4)}`);
> }
>
> console.log('\nRetrieving vector details...');
> const retrieved = await client.points.get(COLLECTION, [results[0].id]);
> console.log(`Top result payload: ${JSON.stringify(retrieved[0].payload)}`);
> ```
>
> The following output is an example. Your scores will vary.
>
> ```
> Searching for similar vectors...
> Found 5 results:
> [1] ID: 39, Score: 29.2119
> [2] ID: 54, Score: 27.3639
> [3] ID: 76, Score: 23.6023
> [4] ID: 31, Score: 21.2087
> [5] ID: 22, Score: 17.9858
>
> Retrieving vector details...
> Top result payload: {"price":451.6,"id":39,"in_stock":false,"category":"electronics"}
> ```
>
> ## Step 5: Delete collection
>
> ```typescript theme={null}
> await client.collections.delete(COLLECTION);
> console.log(`Collection '${COLLECTION}' deleted successfully`);
>
> client.close();
> ```

## Next steps

> [card] [Core concepts](https://docs.vectoraidb.actian.com/home/getting-started/overview.md)
>
> Understand the data model, architecture, and how search works.

> [card] [Python SDK reference](https://docs.vectoraidb.actian.com/sdks/python/reference.md)
>
> Namespaces, configuration, filters, and error handling.

> [card] [JavaScript SDK reference](https://docs.vectoraidb.actian.com/sdks/javascript/reference.md)
>
> Client setup, namespaces, and TypeScript types.

> [card] [Integrations](https://docs.vectoraidb.actian.com/docs/integrations/index.md)
>
> Connect VectorAI DB to LangChain and LlamaIndex.

> [card] [Academy](https://docs.vectoraidb.actian.com/academy/tutorials.md)
>
> Tutorials for semantic search, hybrid search, RAG, and more.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.