> ## 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.

# Load Index

Loads an existing encrypted index and returns an `EncryptedIndex` bound to it.

```python theme={null}
client.load_index(
    index_name,
    index_key = None,
)
```

### Parameters

| Parameter | Type | Default | Description |
| - | - | - | - |
| `index_name` | `str` | - | Name of an existing index. |
| `index_key` | `bytes` | `None` | *(Optional)* The 32-byte key the index was created with. Required for SDK-supplied-key indexes; omit it for KMS-backed indexes (created with `kms_name`). |

<Warning>For SDK-supplied-key indexes, `index_key` must be the exact key passed to `create_index()`. A KMS-backed index fails to load if its `kms_name` slot is missing from the service YAML or its provider is unreachable, with `cyborgdb.AuthenticationError` (HTTP `401`).</Warning>

### Returns

An `EncryptedIndex` bound to the loaded index.

### Exceptions

<AccordionGroup>
  <Accordion title="cyborgdb.ValidationError">
    `index_key` is passed but is not 32 bytes. Raised before any request is sent.
  </Accordion>

  <Accordion title="cyborgdb.NotFoundError">
    No index named `index_name` exists, or `index_key` doesn't match (HTTP `404`, in most cases).
  </Accordion>

  <Accordion title="cyborgdb.AuthenticationError">
    `index_key` doesn't match an index that has vectors and is already in the service's cache, or the client's `api_key` is missing or invalid; or, for a KMS-backed index, its KMS slot is missing or the provider call fails (HTTP `401`).
  </Accordion>

  <Accordion title="cyborgdb.ServiceError">
    The service returns `5xx`.
  </Accordion>

  <Accordion title="cyborgdb.TransportError">
    The service can't be reached.
  </Accordion>
</AccordionGroup>

See [Errors](../errors) for the full hierarchy.

<Note>A wrong key returns `cyborgdb.AuthenticationError` (HTTP `401`) when the index has vectors and the service already has it cached, and `cyborgdb.NotFoundError` (HTTP `404`) otherwise, for example on an empty index or right after the service restarts. Catch both when checking for a bad key.</Note>

### Example Usage

#### SDK-supplied-key index

```python theme={null}
from cyborgdb import Client

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

# The same 32 bytes that were passed to create_index(), e.g. stored as hex
index_key = bytes.fromhex('your-64-character-hex-key')

index = client.load_index('my_index', index_key)
print(index.index_name)
# Output: my_index
```

#### KMS-backed index

```python theme={null}
# No key needed: the service unwraps it with the index's KMS provider.
index = client.load_index('kms_index')
```


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