VectorAI DB provides high-performance gRPC endpoints for applications that require low-latency operations and efficient binary communication. gRPC uses Protocol Buffers for serialization and HTTP/2 for transport, making it ideal for production workloads with demanding performance requirements.From this page you can learn about the gRPC connection details, understand when to choose gRPC over REST, and run a sample workflow using the Python SDK.
The Python SDK supports gRPC endpoints for communication with VectorAI DB. For more information about using the Python SDK with gRPC endpoints, see Python SDK.
The following example connects to a VectorAI DB gRPC endpoint, creates a collection with 128-dimensional cosine vectors, inserts a point, and runs a similarity search. After running this code you should see the search results printed to the console, confirming that your gRPC connection is working.
from actian_vectorai import ( Distance, PointStruct, VectorAIClient, VectorParams,)# Connect to gRPC endpoint (default port 6574)with VectorAIClient("localhost:6574") as client: # Health check info = client.health_check() print(f"Connected to {info['title']} v{info['version']}") # Create a collection client.collections.create( "my_collection", vectors_config=VectorParams(size=128, distance=Distance.Cosine), ) # Insert a point client.points.upsert( "my_collection", points=[ PointStruct( id=1, vector=[0.1] * 128, payload={"category": "example"} ) ] ) # Perform search operations results = client.points.search( "my_collection", vector=[0.1] * 128, limit=10 ) print(f"Found {len(results)} results")