This guide shows how to create an embedding for a single image using the Marengo video understanding model. For a list of available versions, complete specifications, and input requirements, see the Marengo page. To create a combined embedding from multiple images with optional text, see the Text and image embeddings page.
The Marengo video understanding model generates embeddings for all modalities in the same latent space. This shared space enables any-to-any searches across different types of content.
For details on how your usage is measured and billed, see the Pricing page.
This section explains the key concepts and terminology used in this guide:
This guide shows how to upload your image as an asset and create an embedding synchronously. You can also pass a URL or base64-encoded data inline instead of creating an asset; both are shown as commented-out lines in the code examples.
Use these embeddings for similarity search, content classification, clustering, recommendations, or Retrieval-Augmented Generation (RAG).
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 image files must meet the requirements.
Copy and paste the code below, replacing the placeholders surrounded by <> with your values.
Create a client instance to interact with the TwelveLabs Video Understanding Platform.
Function call: You call the constructor of the TwelveLabs class.
Parameters:
api_key: The API key to authenticate your requests to the platform.Return value: An object of type TwelveLabs configured for making API calls.
Upload an image file to create an asset.
Function call: You call the assets.create function.
Parameters:
method: The upload method for your asset. Use url for a publicly accessible or direct to upload a local file. This example uses url.url or file: The publicly accessible URL of your image file or an opened file object in binary read mode. This example uses url.Return value: An object of type Asset. This object contains, among other information, a field named id representing the unique identifier of your asset.
Function call: You call the embed.v_2.create function.
Parameters:
input_type: The type of content. Set this parameter to image.model_name: The model you want to use. This example uses marengo3.0.image: An ImageInputRequest object containing the following properties:
media_source: An object specifying the source of the image file. Specify one of the following:
asset_id: The unique identifier of an asset from a previous upload.
url: The publicly accessible URL of the image file.
base_64_string: The base64-encoded image data.
This example uses the asset ID from the previous step.
Return value: An object of type EmbeddingSuccessResponse containing a field named data, which is a list of embedding objects. Each embedding object includes the following fields:
embedding: An array of floats representing the embedding vector.embedding_option: The type of embedding generated.