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.v2.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. Requires Marengo 3.0. The decoded file can be up to 32 MB.
TextImageInputRequest
The TwelvelabsApi.TextImageInputRequest interface specifies the configuration for processing combined text and image content. Required when inputType is text_image. Requires Marengo 3.0. The decoded file can be up to 32 MB.
AudioInputRequest
The TwelvelabsApi.AudioInputRequest interface specifies the configuration for processing audio content. Required when inputType is audio. Requires Marengo 3.0. The decoded file can be up to 36 MB.
VideoInputRequest
The TwelvelabsApi.VideoInputRequest interface specifies the configuration for processing video content. Required when inputType is video. Requires Marengo 3.0. The decoded file can be up to 36 MB.
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, audio, and documents as media sources. Marengo 3.0 accepts images.
Include text in the inputText field when you combine media sources of different types. For example, if you combine an image and a video without text, the platform returns a 400 error. Media sources of the same type do not require text.
Document sources
The platform embeds a plain text or Markdown document as text. Combining content into a single embedding requires at least one image, video, or audio source; if the content is all text, the platform returns a 400 error. A plain text or Markdown document combined with the inputText field, and two plain text documents, are both all-text content. Send a single text document as your only source, use the inputText field on its own, or add an image, video, or audio source.
A PDF document must be your only source. You cannot combine it with any other media source, including another document, or with the inputText field; the platform returns a 400 error if you do. To combine document content with an image, video, or audio source, send a plain text or Markdown document instead of a PDF file.
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. If your content exceeds either limit, the platform returns either a 400 or a 413 error. A PDF file also has a page allowance: 16 pages for each MB of file size. A 0.5 MB file is allowed 16 pages, and a 4 MB file is allowed 64 pages. The platform checks the page count of the file against the allowance before processing the file. If the file exceeds the allowance, the platform returns a 413 error. The error message includes the page count and the allowance. Plain text and Markdown files have no page allowance.
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.