Create sync embeddings
The EmbedClient.V2Client class provides methods to create embeddings synchronously for multimodal content, returning 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.v_2.tasks.create method instead.
The content this method accepts depends on the model. With Marengo 3.5, this method accepts only the multi_input 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
TextInputRequest
The TextInputRequest class specifies the configuration for processing text content. Required when input_type is text.
ImageInputRequest
The ImageInputRequest class specifies the configuration for processing image content. Required when input_type is image. Requires Marengo 3.0. The decoded file can be up to 32 MB.
TextImageInputRequest
The TextImageInputRequest class specifies the configuration for processing combined text and image content. Required when input_type is text_image. Requires Marengo 3.0. The decoded file can be up to 32 MB.
AudioInputRequest
The AudioInputRequest class specifies the configuration for processing audio content. Required when input_type is audio. Requires Marengo 3.0. The decoded file can be up to 36 MB.
VideoInputRequest
The VideoInputRequest class specifies the configuration for processing video content. Required when input_type 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 input_type is multi_input.
Marengo 3.5 accepts images, video, audio, and documents 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, 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 input_text field, and two plain text documents, are both all-text content. Send a single text document as your only source, use input_text 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 input_text 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 MediaSource class 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, base_64_string, or asset_id 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 AudioSegmentation class specifies how the platform divides the audio into segments using fixed-length intervals.
AudioSegmentationFixed
The AudioSegmentationFixed class configures fixed-length segmentation for audio.
VideoSegmentation
The 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 VideoSegmentationFixedFixed class configures fixed-length segmentation for video.
VideoSegmentationDynamicDynamic
The VideoSegmentationDynamicDynamic class configures dynamic segmentation for video based on scene changes.
Return value
Returns an EmbeddingSuccessResponse object containing the embedding results.
The EmbeddingSuccessResponse class contains the following properties:
The EmbeddingData class contains the following properties:
EmbeddingUsage
The EmbeddingUsage class provides token counts for the request. Only Marengo 3.5 returns this object.
EmbeddingMediaMetadata
The EmbeddingMediaMetadata type provides metadata for the media input. Available for the image, text_image, audio, video, and multi_input input types. The input_type 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.