Quickstart

Private beta

Video agents (Jockey) are in private beta. Availability, limits, and API behavior may change before general availability.

This guide shows how to upload a video, build a knowledge store, and generate an overview of your video content. Additionally, the platform allows for entity extraction and tracking, search functionality, content organization, and more. To explore the capabilities of the platform, see the Guides section. For common tasks and multi-step workflows, see the Recipes section.

Key concepts

This section explains the key concepts and terminology used in this guide:

  • Asset: Your uploaded content. Once created, you can reference the same asset across multiple operations without uploading the file again.
  • Knowledge store: A persistent store of your videos plus the understanding the platform derives from them - spatiotemporal context, a typed ontology, and embeddings - that together enable corpus-level reasoning.
  • Ingestion configuration: An optional set of instructions that controls what the platform extracts during indexing. You can provide a natural-language description or a JSON schema.
  • Knowledge store item: An asset added to a knowledge store. The platform processes each item asynchronously. When processing finishes, the item is ready for downstream tasks.

Workflow

Upload your video as an asset, then create a knowledge store. Add the asset to the knowledge store. The platform indexes the content asynchronously. When processing finishes, use the Responses API to generate a response from the knowledge store. Note that this guide includes an optional ingestion configuration to show how to guide extraction.

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.

  • Python 3.8+ with requests installed:

    $pip install requests
  • A publicly accessible video URL that points directly to a media file. This quickstart demonstrates the URL upload method. For local file uploads, see the Upload content page.

  • Upload limits: Public video URLs up to 2 GB or local video files up to 200 MB. For local files up to 2 GB, see the Upload content page.

Starter code

Copy and paste the code below, replacing the placeholders surrounded by <> with your values.

1import requests
2import time
3
4API_KEY = "<YOUR_API_KEY>"
5BASE_URL = "https://api.twelvelabs.io/v1.3"
6HEADERS = {"x-api-key": API_KEY}
7
8# Step 1: Upload a video and wait until the asset is ready
9response = requests.post(
10 f"{BASE_URL}/assets",
11 headers=HEADERS,
12 files=[("method", (None, "url")), ("url", (None, "<YOUR_VIDEO_URL>"))]
13)
14asset_id = response.json()["_id"]
15print(f"Asset created: {asset_id}")
16
17while True:
18 status = requests.get(f"{BASE_URL}/assets/{asset_id}", headers=HEADERS).json()["status"]
19 if status == "ready":
20 break
21 elif status == "failed":
22 raise Exception("Asset processing failed")
23 print(f"Status: {status}, waiting...")
24 time.sleep(5)
25print("Asset ready")
26
27# Step 2: Create a knowledge store with an ingestion config (optional but recommended)
28response = requests.post(
29 f"{BASE_URL}/knowledge-stores",
30 headers={**HEADERS, "Content-Type": "application/json"},
31 json={
32 "name": "My First Knowledge Store",
33 "ingestion_config": {
34 "enrichment_config": {
35 "description": "Extract key topics, themes, people, locations, and notable events"
36 }
37 }
38 }
39)
40store_id = response.json()["_id"]
41print(f"Knowledge store created: {store_id}")
42
43# Step 3: Add the video to the knowledge store and wait until indexing completes
44response = requests.post(
45 f"{BASE_URL}/knowledge-stores/{store_id}/items",
46 headers={**HEADERS, "Content-Type": "application/json"},
47 json={"asset_id": asset_id}
48)
49item_id = response.json()["_id"]
50print(f"Item added: {item_id}")
51
52while True:
53 status = requests.get(
54 f"{BASE_URL}/knowledge-stores/{store_id}/items/{item_id}",
55 headers=HEADERS
56 ).json()["status"]
57 if status == "ready":
58 break
59 elif status == "failed":
60 raise Exception("Indexing failed")
61 print(f"Status: {status}, waiting...")
62 time.sleep(10)
63print("Indexing complete")
64
65# Step 4: Generate a response
66response = requests.post(
67 f"{BASE_URL}/responses",
68 headers={**HEADERS, "Content-Type": "application/json"},
69 json={
70 "model": "jockey1.0",
71 "input": [
72 {"type": "message", "role": "user", "content": "Give me an overview of this video collection - main themes, key subjects, and any patterns across the videos."}
73 ],
74 "knowledge_store_id": store_id
75 }
76)
77result = response.json()
78for output in result["output"]:
79 if output["type"] == "message":
80 for content in output["content"]:
81 print(content["text"])

Code explanation

1

Upload a video

Upload a video using a publicly accessible URL to create an asset. For URL uploads larger than 200 MB, wait until the asset reaches the ready status. The platform processes these files asynchronously.

2

Create a knowledge store

Create a knowledge store and provide an ingestion config that tells Jockey what to extract. The ingestion config is optional, but it improves the quality of the results. This example uses a natural-language description. The platform also supports defining a JSON schema for structured extraction. For details, see the Configure ingestion page.

3

Add the video to the knowledge store

Add the asset to the knowledge store for indexing. Check the knowledge store item status until it reaches ready. Indexing usually takes longer than the asset processing in step 1.

4

Generate a response

Generate a response from your video collection through the Responses API. This example requests an overview of the main themes, key subjects, and patterns across your videos. The platform searches, tracks entities, and reasons across the knowledge store, then returns a response.

Next steps

  • Guides - set up content, configure ingestion, and generate responses
  • Recipes - common tasks you can adapt to your use case