Skip to main content

Python Client SDK for CyborgDB: The Confidential Vector Database

Project description

CyborgDB Python SDK

PyPI - Version PyPI - License PyPI - Python Version

The CyborgDB Python SDK provides a comprehensive client library for interacting with CyborgDB, the first Confidential Vector Database. This SDK enables you to perform encrypted vector operations including ingestion, search, and retrieval while maintaining end-to-end encryption of your vector embeddings. Built for Python applications, it offers seamless integration into modern Python applications and services.

This SDK provides an interface to cyborgdb-service which you will need to separately install and run in order to use the SDK. For more info, please see our docs

Why CyborgDB?

Vector Search powers critical AI applications like RAG systems, recommendation engines, and semantic search. The CyborgDB Python SDK brings confidential computing to your Python applications and services, ensuring vector embeddings remain encrypted throughout their entire lifecycle while providing fast, accurate search capabilities.

Key Features

  • End-to-End Encryption: All vector operations maintain encryption with client-side keys
  • Batch Operations: Efficient batch queries and upserts for high-throughput applications
  • Flexible Indexing: Support for multiple index types (IVFFlat, IVFPQ, etc.) with customizable parameters

Installation

  1. Install cyborgdb-service
# Install the CyborgDB Service
pip install cyborgdb-service
  1. Install cyborgdb SDK:
# Install the CyborgDB Python SDK
pip install cyborgdb

Usage

from cyborgdb import Client, IndexIVFFlat
import secrets

# Initialize the client
client = Client('https://localhost:8000', 'your-api-key')

# Generate a 32-byte encryption key
index_key = secrets.token_bytes(32)

# Create an encrypted index
index = await client.create_index('my-index', index_key, IndexIVFFlat(128, 1024))

# Add encrypted vector items
items = [
    {
        'id': 'doc1',
        'vector': [([0.1] * 128)],  # Replace with real embeddings
        'contents': 'Hello world!',
        'metadata': {'category': 'greeting', 'language': 'en'}
    },
    {
        'id': 'doc2',
        'vector': [([0.1] * 128)],  # Replace with real embeddings
        'contents': 'Bonjour le monde!',
        'metadata': {'category': 'greeting', 'language': 'fr'}
    }
]

await index.upsert(items)

# Query the encrypted index
query_vector = [0.1, 0.2, 0.3, *([0.0] * 125)]  # 128 dimensions
results = await index.query(query_vector, 10)

# Print the results
for result in results.results:
    print(f"ID: {result.id}, Distance: {result.distance}")

Advanced Usage

Batch Queries

# Search with multiple query vectors simultaneously
query_vectors = [
    [0.1, 0.2, 0.3, *([0.0] * 125)],
    [0.4, 0.5, 0.6, *([0.0] * 125)]
]

batch_results = await index.query(query_vectors, 5)

Metadata Filtering

# Search with metadata filters
results = await index.query(
    query_vector,
    10,      # top_k
    1,       # n_probes
    False,   # greedy
    {'category': 'greeting', 'language': 'en'},  # filters
    ['distance', 'metadata', 'contents']         # include
)

Index Training

# Train the index for better query performance (recommended for IVF indexes)
await index.train(2048, 100, 1e-6)

Documentation

For more detailed documentation, visit:

License

The CyborgDB Python SDK is licensed under the MIT License - see the LICENSE file for details.

About CyborgDB

CyborgDB is dedicated to making AI safe and secure through confidential computing. We develop solutions that enable organizations to leverage AI while maintaining the confidentiality and privacy of their data.

Visit our website | Contact Us

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

cyborgdb-0.11.1a0.tar.gz (11.9 MB view details)

Uploaded Source

Built Distribution

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

cyborgdb-0.11.1a0-py3-none-any.whl (135.9 kB view details)

Uploaded Python 3

File details

Details for the file cyborgdb-0.11.1a0.tar.gz.

File metadata

  • Download URL: cyborgdb-0.11.1a0.tar.gz
  • Upload date:
  • Size: 11.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for cyborgdb-0.11.1a0.tar.gz
Algorithm Hash digest
SHA256 9e22fc937f588b8aa488e552b9eeee63f9e2a1972a0c881fba9469e1d251e7d3
MD5 2c2f7142a9be774646ec776e73716cc0
BLAKE2b-256 560bd2142ffbdda3008fe2852a43f4b0151d85959a76ee4e9f9ca43788fb92df

See more details on using hashes here.

Provenance

The following attestation bundles were made for cyborgdb-0.11.1a0.tar.gz:

Publisher: build_and_package_wheels.yml on cyborginc/cyborgdb-py

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

File details

Details for the file cyborgdb-0.11.1a0-py3-none-any.whl.

File metadata

  • Download URL: cyborgdb-0.11.1a0-py3-none-any.whl
  • Upload date:
  • Size: 135.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for cyborgdb-0.11.1a0-py3-none-any.whl
Algorithm Hash digest
SHA256 184581886777b652dc9198a9d87117d767dffdcce2cb71efbc8db730ab2b062e
MD5 43856c88b03d0258f9edced4bc97af44
BLAKE2b-256 ecd492165aa9a3590c81c14f85844bf4bf2fd0b0f52a4abcd1c85d403c39668b

See more details on using hashes here.

Provenance

The following attestation bundles were made for cyborgdb-0.11.1a0-py3-none-any.whl:

Publisher: build_and_package_wheels.yml on cyborginc/cyborgdb-py

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