DEVELOPER HUB

Explore our guides and examples to integrate TwelveLabs

Easily build features like semantic search, anomaly detection, content recommenders and capabilities tailored to you. Our API unlocks your video’s full potential.

Try our API.

Get your API keys from the API Keys dashboard (see the authentication guide) and ensure the TwelveLabs SDK is installed on your computer:

pip install twelvelabs

You can copy and paste the code below to analyze videos and generate text based on their content. Replace the placeholders surrounded by <> with your values.

from twelvelabs import TwelveLabs

from twelvelabs.indexes import IndexesCreateRequestModelsItem

from twelvelabs.tasks import TasksRetrieveResponse

 

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

 

index = client.indexes.create(

index_name="<YOUR_INDEX_NAME>",

models=[

IndexesCreateRequestModelsItem(

model_name="pegasus1.2", model_options=["visual", "audio"]

)

]

)

print(f"Created index: id={index.id}")

 

task = client.tasks.create(

index_id=index.id, video_url="<YOUR_VIDEO_URL>")

print(f"Created task: id={task.id}")

 

def on_task_update(task: TasksRetrieveResponse):

print(f" Status={task.status}")

 

task = client.tasks.wait_for_done(task_id=task.id, callback=on_task_update)

if task.status != "ready":

raise RuntimeError(f"Indexing failed with status {task.status}")

print(

f"Upload complete. The unique identifier of your video is {task.video_id}.")

 

text_stream = client.analyze_stream(video_id=task.video_id, prompt="<YOUR_PROMPT>")

for text in text_stream:

if text.event_type == "text_generation":

print(text.text)

For more information, visit our Quickstart documentation or test in the Playground sandbox.

Our stable of models.

Learn more about TwelveLabs’ world-leading video foundation models.

Learn more
Animated pixel horse running

Marengo

Our breakthrough video foundation model analyzes frames and their temporal relationships, along with speech and sound — a huge leap forward for search and any-to-any retrieval tasks.

Animated pixel winged horse flying

Pegasus

Our powerful video-first language model integrates visual, audio, and speech information — and employs this deep video understanding to reach new heights in text generation.

Support and guidance

Contact

Have a question? Get in touch with a member of the TwelveLabs team for help.

Contact us

Community

Connect with the TwelveLabs community for ideas, tips, and knowledge sharing.

Discord