For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Sample appsIntegrationsDiscordPlaygroundDevEx repo
GuidesSDK ReferenceAPI Reference
GuidesSDK ReferenceAPI Reference
  • TwelveLabs API
    • Introduction
    • Authentication
  • API Reference
    • Manage indexes
    • Upload content
    • Index content
    • Manage videos
    • Manage entities
    • Any-to-video search
    • Create embeddings v2
    • Create embeddings v1
    • Analyze and segment videos
    • Error codes
LogoLogo
Sample appsIntegrationsDiscordPlaygroundDevEx repo
On this page
  • Prerequisites
  • Procedure
TwelveLabs API

Authentication

Was this page helpful?
Previous

Manage indexes

Next
Built with

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:

1

If you don’t have an account, sign up for a free account.

2

Go to the API Keys page.

3

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.

4

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

Procedure

1

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

Python
Node.js

Install the requests package by entering the following command:

$python -m pip install requests
2

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

3

Create the necessary headers for authentication.

4

Prepare the data payload for your API request.

5

Send the API request and process the response.

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

1import requests
2
3# Step 2: Define the API URL and the specific endpoint
4API_URL = "https://api.twelvelabs.io/v1.3"
5INDEXES_URL = f"{API_URL}/indexes"
6
7# Step 3: Create the necessary headers for authentication
8headers = {
9 "x-api-key": "<YOUR_API_KEY>"
10}
11
12# Step 4: Prepare the data payload for your API request
13INDEX_NAME = "<YOUR_INDEX_NAME>"
14data = {
15 "models": [
16 {
17 "model_name": "marengo3.0",
18 "model_options": ["visual", "audio"]
19 }
20 ],
21 "index_name": INDEX_NAME
22}
23
24# Step 5: Send the API request and process the response
25response = requests.post(INDEXES_URL, headers=headers, json=data)
26print(f"Status code: {response.status_code}")
27if response.status_code == 201:
28 print(response.json())
29else:
30 print("Error:", response.json())