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 byembed_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_videois opt-in and disabled by default.
Prerequisites
You need to install thetwelvelabs library and an API key which can be obtained from the TwelveLabs dashboard.
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