> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.twelvelabs.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.twelvelabs.io/_mcp/server.

# The TwelveLabs class

> Initialize the Python SDK client.

The `TwelveLabs`  class is the main entry point for the SDK. It initializes the client and provides access to resources for uploading videos, managing indexes, performing searches, creating embeddings, and analyzing videos.

# Methods

## The initializer

**Description**: The constructor creates a new instance of the `TwelveLabs` class.

**Function signature and example**:

**`Function signature`**

```python Function signature
def __init__(
    self,
    *,
    api_key: typing.Optional[str] = None,
    **kwargs,
)
```

**`Python example`**

```python Python example
from twelvelabs import TwelveLabs

client = TwelveLabs(api_key="<YOUR_API_KEY>")
```

### Parameters

| Name       | Type                   | Required | Description                                                                                                                                                                                                                                                                                                                                                                                                                              |
| :--------- | :--------------------- | :------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `api_key`  | `typing.Optional[str]` | Yes      | Your TwelveLabs API key. If not provided, the `TWELVE_LABS_API_KEY` environment variable will be used.                                                                                                                                                                                                                                                                                                                                   |
| `**kwargs` | `dict`                 | No       | Additional parameters to pass to the base client. You can pass a variable named `timeout` of type `float` to set the request timeout in seconds. The default timeout is 600 seconds, unless you use a custom `httpx` client. For long-running endpoints (`embed` or `analyze` with large inputs), pass a higher value. For fast-fail behavior, pass a lower value, or override per call via `request_options={"timeout_in_seconds": N}`. |

### Return value

`None`. This method initializes the instance.

# Request options

Every method accepts an optional `request_options` argument for per-call configuration. Pass it as a keyword argument:

```python
client.knowledge_stores.list(
    request_options={"timeout_in_seconds": 30},
)
```

The `request_options` argument accepts the following fields:

| Name                          | Type             | Description                                                                                                                                                                                                                                  |
| :---------------------------- | :--------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `timeout_in_seconds`          | `int`            | The request timeout, in seconds, for this call. Overrides the client's default timeout of 600 seconds. For long-running endpoints (`embed` or `analyze` with large inputs), pass a higher value. For fast-fail behavior, pass a lower value. |
| `max_retries`                 | `int`            | The maximum number of retries to attempt if the API call fails.                                                                                                                                                                              |
| `additional_headers`          | `Dict[str, Any]` | Additional headers to include in the request.                                                                                                                                                                                                |
| `additional_query_parameters` | `Dict[str, Any]` | Additional query parameters to include in the request.                                                                                                                                                                                       |
| `additional_body_parameters`  | `Dict[str, Any]` | Additional body parameters to include in the request.                                                                                                                                                                                        |