Creates and returns an EncryptedIndex instance based on the provided configuration.
client.create_index(
    index_name,
    index_key,
    index_config = None,
    embedding_model = None,
    metric = "euclidean",
)

Parameters

ParameterTypeDefaultDescription
index_namestr-Unique name for the index
index_keybytes-32-byte encryption key
index_configIndexConfigNone(Optional) Index configuration object
embedding_modelstrNone(Optional) Embedding model identifier
metricstr"euclidean"(Optional) Distance metric to use ("euclidean", "squared_euclidean", or "cosine")

Returns

An instance of EncryptedIndex configured with the provided parameters.

Exceptions

Example Usage

Automatic Index Config

from cyborgdb import Client

# Initialize client
client = Client(base_url='http://localhost:8000', api_key='your-api-key')

# Generate a secure encryption key
index_key = client.generate_key()

# Create an index
index = client.create_index('documents', index_key)
For more info on generate_key, refer to Generate Key.

IVFFlat Index

from cyborgdb import Client, IndexIVFFlat

# Initialize client
client = Client(base_url='http://localhost:8000', api_key='your-api-key')

# Generate a secure encryption key
index_key = client.generate_key()

# Create a basic IVFFlat index
config = IndexIVFFlat()
index = client.create_index('documents', index_key, config)

IVFPQ Index with Embedding Model

from cyborgdb import Client, IndexIVFPQ

# Initialize client
client = Client(base_url='http://localhost:8000', api_key='your-api-key')

# Generate a secure encryption key
index_key = client.generate_key()

# Create an IVFPQ index with automatic embedding generation
config = IndexIVFPQ(pq_dim=64, pq_bits=8)
index = client.create_index('documents', index_key, config, embedding_model='all-MiniLM-L6-v2')
For more info on auto-generating embeddings, refer to Auto-Generate Embeddings.