Skip to main content
TwelveLabsTools enable an Agent to understand and search video using TwelveLabs. The toolkit exposes three capabilities:
  • analyze_video: answers a natural-language question about a video using the Pegasus video understanding model.
  • embed_text: generates a multimodal embedding with the Marengo model that lives in the same latent space as TwelveLabs video, audio and image embeddings (useful for searching a video corpus by text).
  • embed_video: embeds a whole video into the same Marengo latent space (one vector per 2–10s segment). Video embedding is asynchronous, so the tool creates an embedding task, polls until it finishes (bounded by embed_timeout), and returns a compact summary of the segmentation (segment count, embedding dimensionality, and each segment’s time offsets and scope) rather than the raw float vectors. Because it is long-running, embed_video is opt-in and disabled by default.

Prerequisites

You need to install the twelvelabs library and an API key which can be obtained from the TwelveLabs dashboard.
Set the TWELVELABS_API_KEY and OPENAI_API_KEY environment variables.

Example

The following agent will use TwelveLabs to answer a question about a video and to generate a text embedding.
cookbook/91_tools/twelvelabs_tools.py

Toolkit Params

Toolkit Functions

Developer Resources