> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cyborg.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a New Encrypted Index

To create an encrypted index, you need to specify an index name (must be unique) and an index key:

<CodeGroup>
  ```python Python icon="python" theme={null}
  import cyborgdb_core as cyborgdb
  import secrets

  # Create a client (use the same backing store you'll load the index with)
  client = cyborgdb.Client(storage_config=cyborgdb.StorageConfig.disk("/tmp/cyborgdb"))

  # Generate an encryption key for the index
  index_key = secrets.token_bytes(32)

  # Create an encrypted index
  index = client.create_index("my_index", index_key)
  ```
</CodeGroup>

This creates a new encrypted index. The vector dimension is auto-detected from the first upsert (or derived from an `embedding_model`); you can also set it explicitly with the keyword-only `dimension` parameter. Other optional parameters include `metric` (`"euclidean"` default, `"cosine"`, or `"squared_euclidean"`) and `storage_precision`. `storage_precision` picks the on-disk format for the rerank vectors: `"float32"` (default) or `"float16"` to halve the footprint at a slight precision cost, or one of the TurboQuant tiers `"tq12"` / `"tq8"` / `"tq6"` / `"tq4"` (12/8/6/4 bits per dimension) to trade storage for a small recall/latency cost — `"tq4"` is the most aggressive (\~8x smaller than `float32`, \~94% recall\@100 on a 768-dimensional benchmark dataset). All tiers work with every metric; the choice is fixed at create time.

<Note>Vector dimension is capped at **65535** (`0xFFFF`). Passing `dimension=0` still means auto-detect. Explicit values outside `[0, 65535]`, including negatives, raise `ValueError` at `create_index()` time.</Note>

<Warning>
  **Store `index_key` before you upsert any data.** CyborgDB has no key-recovery path — data encrypted with a lost key is unrecoverable. For anything past evaluation, keep the key in AWS Secrets Manager, Vault, or your KMS. See [Managing Keys](../advanced/managing-keys).
</Warning>

<Note>To lift the free-tier 1M-items-per-index cap, pass an API key as the first argument (`cyborgdb.Client(api_key, storage_config=...)`). Get a key from the [CyborgDB Admin Dashboard](https://cyborgdb.co/new). See [Get an API Key](../../../intro/get-api-key).</Note>

## Automatic Embedding Generation

<Tip>Text embedding is built into `cyborgdb-core` — no `[embeddings]` extra or `sentence-transformers`/`torch` install required. Call `cyborgdb.supported_embedding_models()` for the accepted model names.</Tip>

Enable automatic embedding generation for the encrypted index by setting `embedding_model` in `create_index()`:

```python Python icon="python" theme={null}
import cyborgdb_core as cyborgdb
import secrets

# Create a client (use the same backing store you'll load the index with)
client = cyborgdb.Client(storage_config=cyborgdb.StorageConfig.disk("/tmp/cyborgdb"))

# Generate an encryption key for the index
index_key = secrets.token_bytes(32)

# Create an encrypted index with managed embedding generation
index = client.create_index(
    "my_index",
    index_key,
    embedding_model="all-MiniLM-L6-v2"
)
```

## API Reference

For more information on creating encrypted indexes, refer to the API reference:

<CardGroup cols={2}>
  <Card title="Python API Reference" href="../../python/client/create-index" icon="python">
    API reference for `create_index()` in Python
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.