Create embeddings
This quickstart guide provides a simplified introduction to creating embeddings using the TwelveLabs Video Understanding Platform. It includes the following:
- A working example for each method: embed a query and embed content at scale
- Minimal implementation details
- Core parameters for common use cases
For comprehensive guides, see the Create embeddings 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.
- Embedding: Vector representation of your content.
- Embedding task: An asynchronous operation for processing your content and creating embeddings. Contains a status and the resulting embeddings when complete.
Workflow
The platform provides two methods to create embeddings. Choose the method that fits your use case:
Embed the text and media you search with. Returns one embedding in the response.
Embed the files you search through, one per request. Returns a task to poll.
Use these embeddings for similarity search, content classification, clustering, recommendations, or Retrieval-Augmented Generation (RAG).
Prerequisites
-
To use the platform, you need an API key:
-
Depending on the programming language you are using, install the TwelveLabs SDK by entering one of the following commands:
-
Your media files must meet the following requirements:
- Embed a query: Up to 10 media sources (images, video, or audio). Each media source can be up to 32 MB, and video and audio can be up to 30 seconds. Your text can be up to 2,000 tokens.
- Embed content at scale: Public video and audio URLs up to 4 GB, local video and audio files up to 200 MB, and images up to 32 MB. For local files up to 4 GB, see the Upload and processing methods page. For documents, local files up to 200 MB or public URLs up to 512 MB.
- Model capabilities: See the complete input requirements for Marengo 3.5.
Embed a query
Create a single embedding from your text. To create a combined embedding, add up to 10 image, video, or audio files to your request. The platform processes your request synchronously and returns the embedding in the response.
Starter code
Copy and paste the code below, replacing the placeholders surrounded by <> with your values.
Code explanation
Import the SDK and initialize the client
Create a client instance to interact with the TwelveLabs Video Understanding Platform.
Embed content at scale
Create embeddings for your media files: video, audio, images, and documents. The platform processes your files asynchronously, one file per request. Use this method for long files and large collections. This example embeds one video; repeat the request for each file. The request differs for each type of content.
Embeddings created with the asynchronous method are stored for seven days. After this, you must recreate them to obtain the results again.
Starter code
Copy and paste the code below, replacing the placeholders surrounded by <> with your values.