Build
Namespaces
Partition data within a project using logical namespaces for multi-tenant or multi-environment setups.
Overview
Namespaces partition data inside a single project. Use them to separate datasets, tenants, or environments without creating additional projects. Each namespace is an isolated partition — the same document ID can exist in multiple namespaces without colliding.
Usage
namespaces.py
import os
from kyrodb import KyroDBClient
with KyroDBClient(
target=os.environ["KYRODB_GRPC_ENDPOINT"],
api_key=os.environ["KYRODB_API_KEY"],
) as client:
# Insert into the "products" namespace
client.insert(
doc_id=1,
embedding=[0.1, 0.2, 0.3, 0.4],
metadata={"name": "Widget A"},
namespace="products",
)
# Insert the same ID into a different namespace
client.insert(
doc_id=1,
embedding=[0.4, 0.5, 0.6, 0.7],
metadata={"ticket": "T-1234"},
namespace="support",
)
# Search only within "products"
results = client.search(
query_embedding=[0.1, 0.2, 0.3, 0.4],
k=5,
namespace="products",
)Default Namespace
If you omit the namespace parameter, all operations use the default namespace automatically.
Common Patterns
| Use Case | Namespace Strategy |
|---|---|
| Multi-tenant SaaS | One namespace per tenant: tenant-123, tenant-456 |
| Environment separation | production, staging, development |
| Data categories | products, support-tickets, documentation |
| A/B testing | index-v1, index-v2 |
Namespace vs. Project
Choose the right isolation level for your use case:
| Need | Use |
|---|---|
| Logical data separation within one app | Namespace |
| Different embedding dimensions | Separate project |
| Different distance metrics | Separate project |
| Different regions | Separate project |
| Separate API key boundary | Separate project |
Next Steps
- Python SDK for the full API reference including namespace parameters on every operation.
- Projects for when to create new projects vs. namespaces.