Skip to main content

Official Python SDK for KyroDB

Project description

KyroDB Python SDK (kyrodb)

Official Python SDK for KyroDB gRPC APIs.

This SDK provides:

  • Sync + async clients with matching behavior.
  • Typed public response models (no protobuf objects in public returns).
  • Strict input validation for IDs, vectors, filters, and call options.
  • Production-oriented reliability defaults (timeouts, retries, circuit breaker support).
  • TLS + API-key authentication, including key rotation providers.

Install

pip install kyrodb

Optional extras:

pip install "kyrodb[dev]"    # lint/type/test tooling
pip install "kyrodb[proto]"  # protobuf regeneration tooling
pip install "kyrodb[docs]"   # MkDocs toolchain
pip install "kyrodb[numpy]"  # faster vector validation path

Quick Start (Sync)

from kyrodb import KyroDBClient

with KyroDBClient(target="127.0.0.1:50051", api_key="kyro_live_key") as client:
    client.wait_for_ready(timeout_s=5.0)

    client.insert(
        doc_id=1,
        embedding=[0.0] * 768,
        metadata={"tenant": "acme", "source": "sdk-readme"},
        namespace="default",
    )

    result = client.search(
        query_embedding=[0.0] * 768,
        k=10,
        namespace="default",
    )
    print(result.total_found)

Quick Start (Async)

import asyncio
from kyrodb import AsyncKyroDBClient


async def main() -> None:
    async with AsyncKyroDBClient(target="127.0.0.1:50051", api_key="kyro_live_key") as client:
        await client.wait_for_ready(timeout_s=5.0)
        await client.insert(
            doc_id=1,
            embedding=[0.0] * 768,
            metadata={"tenant": "acme"},
            namespace="default",
        )
        result = await client.search(
            query_embedding=[0.0] * 768,
            k=10,
            namespace="default",
        )
        print(result.total_found)


asyncio.run(main())

Core Behavior

Public API contract

  • Public SDK surface is what is exported from src/kyrodb/__init__.py.
  • kyrodb._generated.* is internal implementation detail and not part of compatibility guarantees.

Error model

All RPC failures map to typed exceptions under KyroDBError, including:

  • AuthenticationError
  • PermissionDeniedError
  • InvalidArgumentError
  • NotFoundError
  • QuotaExceededError
  • DeadlineExceededError
  • ServiceUnavailableError
  • CircuitOpenError

Timeouts, retries, and circuit breaker

  • Default call timeout is 30.0s.
  • timeout_s=None explicitly requests unbounded timeout.
  • Read-like operations are retry-enabled by default; writes are not.
  • Retries use bounded exponential backoff with jitter and elapsed-time budget.
  • Optional circuit breaker can fail fast under sustained transient failures.
  • Use RetryPolicy.no_retry() for benchmark, load-test, or latency-profiling runs where hidden retries would distort measurements.

Transport defaults

By default:

  • gRPC keepalive is enabled.
  • Send/receive message limits are set to 64 MiB.
  • One client/channel should be reused per process/worker.

Filters

Filter builders:

  • exact(key, value)
  • in_values(key, values)
  • range_match(key, gte=..., lte=..., gt=..., lt=...)
  • all_of([...])
  • any_of([...])
  • negate(filter_value)

Example:

from kyrodb import KyroDBClient, all_of, exact, in_values

with KyroDBClient(target="127.0.0.1:50051", api_key="kyro_live_key") as client:
    filt = all_of([exact("tenant", "acme"), in_values("tier", ["pro", "enterprise"])])
    result = client.search(query_embedding=[0.0] * 768, k=10, filter=filt, namespace="default")
    print(result.total_found)

Security and TLS

from kyrodb import KyroDBClient, TLSConfig

with open("ca.pem", "rb") as f:
    ca_pem = f.read()
with open("client.crt", "rb") as f:
    client_crt = f.read()
with open("client.key", "rb") as f:
    client_key = f.read()

tls = TLSConfig(
    root_certificates=ca_pem,
    certificate_chain=client_crt,
    private_key=client_key,
)

client = KyroDBClient(target="db.internal:50051", api_key="kyro_live_key", tls=tls)

Security notes:

  • Non-loopback targets require TLS.
  • API key is sent as gRPC metadata (x-api-key).
  • mTLS requires both certificate chain and private key.
  • API key rotation:
    • sync: set_api_key(...), set_api_key_provider(...)
    • async: set_api_key(...), set_api_key_provider(...), set_api_key_provider_async(...)

API Surface

Both KyroDBClient and AsyncKyroDBClient provide:

  • insert, bulk_insert, bulk_load_hnsw, delete, update_metadata, batch_delete_ids, batch_delete_filter
  • query, search, bulk_search, bulk_query
  • health, metrics
  • flush_hot_tier, create_snapshot, get_config
  • wait_for_ready, close

Development

python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev,proto]"
python scripts/gen_proto.py --proto proto/kyrodb.proto --out src/kyrodb/_generated

Run local CI parity:

./scripts/run_ci_local.sh

Documentation

  • docs/README.md — docs index
  • docs/api-reference.md — method-level reference
  • docs/operations.md — reliability and runtime behavior
  • docs/troubleshooting.md — operational failure modes
  • docs/performance-benchmarks.md — validation overhead benchmarks

Hosted docs are generated from mkdocs.yml via .github/workflows/docs.yml.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kyrodb-0.2.0.tar.gz (57.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kyrodb-0.2.0-py3-none-any.whl (32.6 kB view details)

Uploaded Python 3

File details

Details for the file kyrodb-0.2.0.tar.gz.

File metadata

  • Download URL: kyrodb-0.2.0.tar.gz
  • Upload date:
  • Size: 57.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for kyrodb-0.2.0.tar.gz
Algorithm Hash digest
SHA256 58d22e918c5d21da82c5a50955decafc81a906df4517a5f5780b4578d36df9b7
MD5 4af8f048642953d34b0be12d7f4369fd
BLAKE2b-256 3dec0d994db70487438a6d80b4f61f18b5501042170e2a01ad2e9f5f2c21a639

See more details on using hashes here.

Provenance

The following attestation bundles were made for kyrodb-0.2.0.tar.gz:

Publisher: release.yml on KyroDB/kyrodb-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kyrodb-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: kyrodb-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 32.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for kyrodb-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aa7ebe5006997ec2484935a527ba4bdb38219793f7b202bfda85f75534698e25
MD5 22c553d16a058dcdb82710603a55d086
BLAKE2b-256 3e102a2753b45f7652e86f74669bc6b548b479ecffc3a5b5e5ec0dc2c48a8024

See more details on using hashes here.

Provenance

The following attestation bundles were made for kyrodb-0.2.0-py3-none-any.whl:

Publisher: release.yml on KyroDB/kyrodb-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page