Skip to content
Github

Quickstart

This guide will have you inserting and searching vectors in under 60 seconds.

Make sure VortexDB is running (see Installation).

from vortexdb import VortexDB, DenseVector, Payload, Similarity
# Connect to VortexDB
db = VortexDB(
grpc_url="localhost:50051",
api_key="your-secure-password"
)
# Insert a vector with a text payload
point_id = db.insert(
vector=DenseVector([0.1, 0.2, 0.3, 0.4]),
payload=Payload.text("Hello, VortexDB!")
)
print(f"Inserted point: {point_id}")
# Clean up
db.close()
from vortexdb import VortexDB, DenseVector, Similarity
db = VortexDB(
grpc_url="localhost:50051",
api_key="your-secure-password"
)
# Search for 5 most similar vectors using cosine similarity
results = db.search(
vector=DenseVector([0.1, 0.2, 0.3, 0.4]),
similarity=Similarity.COSINE,
limit=5
)
print(f"Found {len(results)} similar vectors:")
for point_id in results:
print(f" - {point_id}")
db.close()
# Get the point you just inserted
point = db.get(point_id=point_id)
if point:
print(point.pretty())
# Output:
# Point ID: 550e8400-e29b-41d4-a716-446655440000
# Vector: [0.1, 0.2, 0.3, 0.4]
# Payload: Hello, VortexDB!
db.delete(point_id=point_id)
print("Point deleted successfully")

Here’s a complete example using the Python SDK with context manager:

from vortexdb import VortexDB, DenseVector, Payload, Similarity
# Using context manager for automatic cleanup
with VortexDB(grpc_url="localhost:50051", api_key="secret") as db:
# Insert some vectors
vectors = [
([0.1, 0.2, 0.3, 0.4], "First document"),
([0.2, 0.3, 0.4, 0.5], "Second document"),
([0.9, 0.8, 0.7, 0.6], "Third document"),
]
point_ids = []
for vec, text in vectors:
pid = db.insert(
vector=DenseVector(vec),
payload=Payload.text(text)
)
point_ids.append(pid)
print(f"Inserted: {text} -> {pid}")
# Search for vectors similar to the first one
results = db.search(
vector=DenseVector([0.15, 0.25, 0.35, 0.45]),
similarity=Similarity.COSINE,
limit=2
)
print(f"\nTop 2 similar vectors:")
for pid in results:
point = db.get(point_id=pid)
print(f" - {point.payload.content}")