Create sync embeddings
The Embed.V2 interface provides methods to create embeddings synchronously for multimodal content. It returns embeddings immediately in the response.
Methods
Create sync embeddings
Description: This method synchronously creates embeddings for multimodal content and returns the results immediately in the response.
Use this method to embed a query for retrieving matching content. With Marengo 3.5, audio and video can be up to 30 seconds. With Marengo 3.0, they can be up to 10 minutes. For longer content, use the embed.v2.tasks.create method instead.
The content this method accepts depends on the model. With Marengo 3.5, this method accepts only the multiInput input type; provide text, images, audio, or video as media sources. With Marengo 3.0, use the individual input types. For the formats, resolutions, file sizes, and duration limits each model accepts, see the input requirements for Marengo 3.5 or Marengo 3.0.
This method is rate-limited. With Marengo 3.5, the platform counts input tokens for each type of content. A request can exceed a limit before you see an error. For details, see Input token limits for embedding.
Function signature and example:
Parameters
The TwelvelabsApi.embed.CreateEmbeddingsRequest interface contains the following properties:
TextInputRequest
The TwelvelabsApi.TextInputRequest interface specifies the configuration for processing text content. Required when inputType is text.
ImageInputRequest
The TwelvelabsApi.ImageInputRequest interface specifies the configuration for processing image content. Required when inputType is image.
TextImageInputRequest
The TwelvelabsApi.TextImageInputRequest interface specifies the configuration for processing combined text and image content. Required when inputType is text_image.
AudioInputRequest
The TwelvelabsApi.AudioInputRequest interface specifies the configuration for processing audio content. Required when inputType is audio.
VideoInputRequest
The TwelvelabsApi.VideoInputRequest interface specifies the configuration for processing video content. Required when inputType is video.
MultiInputRequest
The MultiInputRequest class specifies the configuration for processing text and media sources. Required when inputType is multi_input.
Marengo 3.5 accepts images, video, and audio as media sources. Marengo 3.0 accepts images.
Include text in the input_text field when you combine media sources of different types. For example, a request that combines an image and a video returns a 400 error without text. Media sources of the same type do not require text.
Marengo 3.5 accepts images, video, and audio as media sources. Marengo 3.0 accepts images.
MediaSource
The TwelvelabsApi.MediaSource interface specifies the source of the media file. Provide exactly one of the following:
MultiInputMediaSource
A class specifying a media source for multi-input embeddings. You must provide exactly one of the url, base64String, or assetId fields. With Marengo 3.5, each media source can be up to 32 MB, whichever of the three fields you use. Audio and video can be up to 30 seconds. Content above either limit returns a 400 error.
AudioSegmentation
The TwelvelabsApi.AudioSegmentation interface specifies how the platform divides the audio into segments using fixed-length intervals.
AudioSegmentationFixed
The TwelvelabsApi.AudioSegmentationFixed interface configures fixed-length segmentation for audio.
VideoSegmentation
The TwelvelabsApi.VideoSegmentation type specifies how the platform divides the video into segments. Use one of the following:
Fixed segmentation: Divides the video into equal-length segments:
Dynamic segmentation: Divides the video into adaptive segments based on scene changes:
VideoSegmentationFixedFixed
The TwelvelabsApi.VideoSegmentationFixedFixed interface configures fixed-length segmentation for video.
VideoSegmentationDynamicDynamic
The TwelvelabsApi.VideoSegmentationDynamicDynamic interface configures dynamic segmentation for video based on scene changes.
Return value
Returns an HttpResponsePromise that resolves to a TwelvelabsApi.EmbeddingSuccessResponse object containing the embedding results.
The TwelvelabsApi.EmbeddingSuccessResponse interface contains the following properties:
The TwelvelabsApi.EmbeddingData interface contains the following properties:
EmbeddingUsage
The TwelvelabsApi.EmbeddingUsage interface contains token counts for the request. Only Marengo 3.5 returns this object.
EmbeddingMediaMetadata
The TwelvelabsApi.EmbeddingMediaMetadata type provides metadata for the media input. Available for the image, text_image, audio, video, and multi_input input types. The inputType field selects one variant:
Image: Metadata for image embeddings.
Text and image: Metadata for text-image embeddings.
Audio: Metadata for audio embeddings.
Video: Metadata for video embeddings.
Multi-input: Metadata for multi-input embeddings.