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

# Authentication

> Authenticate API requests by including your API key in the request header.

To make HTTP requests, you must include the API key in the header of each request.

# Prerequisites

To use the platform, you need an API key:

If you don't have an account, [sign up](https://playground.twelvelabs.io/) for a free account.

Go to the [API Keys](https://playground.twelvelabs.io/dashboard/api-keys) page.

If you need to create a new key, select the **Create API Key** button. Enter a name and set the expiration period. The default is 12 months.

Select the **Copy** icon next to your key to copy it to your clipboard.

# Procedure

Verify that the required packages are installed on your system. If necessary, install the following packages:

#### Python

Install the `requests` package by entering the following command:

```shell
python -m pip install requests
```

#### Node.js

Install the `axios` and `form-data` packages by entering the following command:

```shell
npm install axios form-data
```

Define the URL of the API and the specific endpoint for your request.

Create the necessary headers for authentication.

Prepare the data payload for your API request.

Send the API request and process the response.

Below are complete code examples for Python and Node.js, integrating all the steps outlined above:

#### Python

**`Python`**

```Python Python
import requests

# Step 2: Define the API URL and the specific endpoint
API_URL = "https://api.twelvelabs.io/v1.3"
INDEXES_URL = f"{API_URL}/indexes"

# Step 3: Create the necessary headers for authentication
headers = {
    "x-api-key": "<YOUR_API_KEY>"
}

# Step 4: Prepare the data payload for your API request
INDEX_NAME = "<YOUR_INDEX_NAME>"
data = {
    "models": [
        {
            "model_name": "marengo3.0",
            "model_options": ["visual", "audio"]
        }
    ],
    "index_name": INDEX_NAME
}

# Step 5: Send the API request and process the response
response = requests.post(INDEXES_URL, headers=headers, json=data)
print(f"Status code: {response.status_code}")
if response.status_code == 201:
    print(response.json())
else:
    print("Error:", response.json())
```

#### Node.js

**`Node.js`**

```Javascript Node.js
const axios = require('axios');

// Step 2: Define the API URL and the specific endpoint
const API_URL = 'https://api.twelvelabs.io/v1.3';
const INDEXES_URL = `${API_URL}/indexes`;

// Step 3: Create the necessary headers for authentication
const headers = {
    'x-api-key': '<YOUR_API_KEY>'
};

// Step 4: Prepare the data payload for your API request
const INDEX_NAME = '<YOUR_INDEX_NAME>';
const data = {
    models: [
        {
            model_name: 'marengo3.0',
            model_options: ['visual', 'audio']
        }
    ],
    index_name: INDEX_NAME
};

// Step 5: Send the API request and process the response
axios.post(INDEXES_URL, data, { headers })
    .then(resp => {
        console.log(`Status code: ${resp.status}`);
        console.log(resp.data);
    })
    .catch(error => {
        console.error(`Error: ${error.response.status} - ${error.response.data.message}`);
    });
```