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.

Note

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

1def create(
2 self,
3 *,
4 input_type: CreateEmbeddingsRequestInputType,
5 model_name: CreateEmbeddingsRequestModelName,
6 auto_truncate: typing.Optional[bool] = OMIT,
7 embedding_uncertainty: typing.Optional[bool] = OMIT,
8 text: typing.Optional[TextInputRequest] = OMIT,
9 image: typing.Optional[ImageInputRequest] = OMIT,
10 text_image: typing.Optional[TextImageInputRequest] = OMIT,
11 audio: typing.Optional[AudioInputRequest] = OMIT,
12 video: typing.Optional[VideoInputRequest] = OMIT,
13 multi_input: typing.Optional[MultiInputRequest] = OMIT,
14 request_options: typing.Optional[RequestOptions] = None,
15) -> EmbeddingSuccessResponse

Parameters

NameTypeRequiredDescription
input_typeCreateEmbeddingsRequestInputTypeYesThe type of content for the embeddings. Values:
- multi_input: Text and up to 10 media sources, combined into a single embedding. To reference a specific media source from your text, use a placeholder in the format <@name>, where name matches the name field of a media source. Marengo 3.5 accepts images, video, and audio as media sources. Marengo 3.0 accepts images.
- audio: An audio file. Requires Marengo 3.0.
- video: A video file. Requires Marengo 3.0.
- image: An image file. Requires Marengo 3.0.
- text: Text input. Requires Marengo 3.0.
- text_image: Text and an image. Requires Marengo 3.0.
model_nameCreateEmbeddingsRequestModelNameYesThe embedding model to use. Values:
- marengo3.5: For details about this version, see the Marengo 3.5 page.
- marengo3.0: For details about this version, see the Marengo 3.0 page.
textTextInputRequestNoText input configuration. Required when input_type is text. See TextInputRequest for details.
imageImageInputRequestNoImage input configuration. Required when input_type is image. See ImageInputRequest for details.
text_imageTextImageInputRequestNoCombined text and image input configuration. Required when input_type is text_image. See TextImageInputRequest for details.
audioAudioInputRequestNoAudio input configuration. Required when input_type is audio. See AudioInputRequest for details.
videoVideoInputRequestNoVideo input configuration. Required when input_type is video. See VideoInputRequest for details.
multi_inputMultiInputRequestNoText and media source configuration. Required when input_type is multi_input. See MultiInputRequest for details.
auto_truncateOptional[bool]NoControls the behavior of the platform when the text in your request exceeds 2,000 tokens. Requires Marengo 3.5. Values:
- False: Return a 400 error.
- True: Truncate your text to fit the limit, and set the usage.truncated field to True in the response.
embedding_uncertaintyOptional[bool]NoSet this parameter to True to receive a data[].embedding_uncertainty field in the response, representing a per-dimension uncertainty vector with the same length as the embedding array. A higher value shows lower confidence in that dimension. Requires Marengo 3.5.

Set this parameter to True only when your request embeds text only, or media only. Requests that combine text with media sources return a 400 error.
request_optionsRequestOptionsNoRequest-specific configuration.

TextInputRequest

The TextInputRequest class specifies the configuration for processing text content. Required when input_type is text.

NameTypeRequiredDescription
input_textstrYesThe text for which you wish to create an embedding. The maximum length is 500 tokens.

ImageInputRequest

The ImageInputRequest class specifies the configuration for processing image content. Required when input_type is image.

NameTypeRequiredDescription
media_sourceMediaSourceYesSpecifies the source of the image file. See MediaSource for details.

TextImageInputRequest

The TextImageInputRequest class specifies the configuration for processing combined text and image content. Required when input_type is text_image.

NameTypeRequiredDescription
media_sourceMediaSourceYesSpecifies the source of the image file. See MediaSource for details.
input_textstrYesThe text for which you wish to create an embedding. The maximum length is 500 tokens.

AudioInputRequest

The AudioInputRequest class specifies the configuration for processing audio content. Required when input_type is audio.

NameTypeRequiredDescription
media_sourceMediaSourceYesSpecifies the source of the audio file. See MediaSource for details.
start_secfloatNoThe start time in seconds for processing the audio file.

Use this parameter to process a portion of the audio file starting from a specific time.

Default: 0 (start from the beginning).
end_secfloatNoThe end time in seconds for processing the audio file.

Use this parameter to process a portion of the audio file ending at a specific time. The end time must be greater than the start time.

Default: End of the audio file
segmentationAudioSegmentationNoSpecifies how the platform divides the audio into segments. See AudioSegmentation for details.
embedding_optionList[str]NoThe types of embeddings you wish to generate.

Values:
- audio: Generates embeddings based on audio content (sounds, music, effects)
- transcription: Generates embeddings based on transcribed speech

You can specify multiple values to generate different types of embeddings for the same audio.

Default: ["audio", "transcription"]
embedding_scopeList[str]NoThe scope for which you wish to generate embeddings.

Values:
- clip: Generates one embedding for each segment
- asset: Generates one embedding for the entire audio file

You can specify multiple scopes to generate embeddings at different levels.

Default: ["clip", "asset"]
embedding_typeList[str]NoSpecifies how to structure the embedding. Include this parameter only when the embedding_option parameter contains at least two values.

Values:
- separate_embedding: Returns separate embeddings for each modality specified in the embedding_option parameter.
- fused_embedding: Returns a single combined embedding that integrates all modalities into one vector.

Specify both values to receive separate and fused embeddings in the same response.

Default: separate_embedding.

VideoInputRequest

The VideoInputRequest class specifies the configuration for processing video content. Required when input_type is video.

NameTypeRequiredDescription
media_sourceMediaSourceYesSpecifies the source of the video file. See MediaSource for details.
start_secfloatNoThe start time in seconds for processing the video file.

Use this parameter to process a portion of the video file starting from a specific time.

Default: 0 (start from the beginning)
end_secfloatNoThe end time in seconds for processing the video file.

Use this parameter to process a portion of the video file ending at a specific time. The end time must be greater than the start time.
Default: End of the video file
segmentationVideoSegmentationNoSpecifies how the platform divides the video into segments. See VideoSegmentation for details.
embedding_optionList[str]NoThe types of embeddings to generate for the video.

Values:
- visual: Generates embeddings based on visual content (scenes, objects, actions)
- audio: Generates embeddings based on audio content (sounds, music, effects)
- transcription: Generates embeddings based on transcribed speech

You can specify multiple values to generate different types of embeddings for the same video.

Default: ["visual", "audio", "transcription"]
embedding_scopeList[str]NoThe scope for which you wish to generate embeddings.

Values:
- clip: Generates one embedding for each segment
- asset: Generates one embedding for the entire video file. Use this scope for videos up to 10-30 seconds to maintain optimal performance.

You can specify multiple scopes to generate embeddings at different levels.

Default: ["clip", "asset"]
embedding_typeList[str]NoSpecifies how to structure the embedding. Include this parameter only when embedding_option contains at least two values.

Values:
- separate_embedding: Returns separate embeddings per modality specified in the embedding_option field
- fused_embedding: Returns a single embedding that combines all modalities into one vector

Specify both values to receive separate and fused embeddings in the same response.

Default: separate_embedding.

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, 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.

NameTypeRequiredDescription
input_textstrNoText to include in the embedding. With Marengo 3.5, the text cannot exceed 2,000 tokens. Use the auto_truncate parameter to control the behavior of the platform when your text exceeds it.

Usage options:
- Provide text without media sources to create a text-only embedding.
- Combine text with media sources to add context. Example: “A person cooking.”
- Use media source references to describe relationships between specific media sources. The format is &lt;@name&gt;, where name matches the name field of a media source. Example: “A person wearing <@outfit> and holding <@accessory>.”
- Omit this field to create an embedding from media sources only.
media_sourcesList[MultiInputMediaSource]NoAn array of up to 10 media sources to include in the embedding. Omit it to create a text-only embedding from the input_text field. The platform processes media sources in the order they appear in the array. If you use media source references in the input_text parameter, each must have a corresponding media source with a matching name field. If a reference has no match, the request fails.

MediaSource

The MediaSource class specifies the source of the media file. Provide exactly one of the following:

NameTypeRequiredDescription
base_64_stringstrNoThe base64-encoded media data.
urlstrNoThe publicly accessible URL of the media file. Use direct links to raw media files. Video hosting platforms and cloud storage sharing links are not supported.
asset_idstrNoThe unique identifier of an asset from a direct or multipart upload. The asset status must be ready. Use assets.retrieve to check the status.

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. Content above either limit returns a 400 error.

NameTypeRequiredDescription
namestrNoThe unique identifier for this media source.

This field is required when input_text references this media source.
media_typeMultiInputMediaSourceMediaTypeNoThe type of media.

Values:
- image: An image file. Works with both Marengo 3.0 and Marengo 3.5.
- video: A video file. Requires Marengo 3.5.
- audio: An audio file. Requires Marengo 3.5.
urlstrNoThe publicly accessible URL of the media file. Use direct links to raw files. Media hosting platforms and cloud storage sharing links are not supported.
base_64_stringstrNoThe base64-encoded media data.
asset_idstrNoThe unique identifier of an asset from a direct or multipart upload.

AudioSegmentation

The AudioSegmentation class specifies how the platform divides the audio into segments using fixed-length intervals.

NameTypeRequiredDescription
strategyLiteral["fixed"]YesThe segmentation strategy. Value: fixed.
fixedAudioSegmentationFixedYesConfiguration for fixed segmentation.

This object is required when the strategy field is fixed. See AudioSegmentationFixed for details.

AudioSegmentationFixed

The AudioSegmentationFixed class configures fixed-length segmentation for audio.

NameTypeRequiredDescription
duration_secintYesThe duration in seconds for each segment. The platform divides the audio into segments of this exact length. The final segment may be shorter if the audio duration is not evenly divisible.

Min: 2.
Max: 10.

Example: With duration_sec: 5, a 12-second audio file produces segments: [0-5s], [5-10s], [10-12s].

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:

NameTypeRequiredDescription
strategyLiteral["fixed"]YesThe segmentation strategy. Value: fixed.
fixedVideoSegmentationFixedFixedYesConfiguration for fixed segmentation. See VideoSegmentationFixedFixed for details.

Dynamic segmentation: Divides the video into adaptive segments based on scene changes:

NameTypeRequiredDescription
strategyLiteral["dynamic"]YesThe segmentation strategy. Value: dynamic.
dynamicVideoSegmentationDynamicDynamicYesConfiguration for dynamic segmentation. See VideoSegmentationDynamicDynamic for details.

VideoSegmentationFixedFixed

The VideoSegmentationFixedFixed class configures fixed-length segmentation for video.

NameTypeRequiredDescription
duration_secintYesThe duration in seconds for each segment.

The platform divides the video into segments of this exact length. The final segment may be shorter if the video duration is not evenly divisible.

Min: 2.
Max: 10.

Example: With duration_sec: 5, a 12-second video produces segments: [0-5s], [5-10s], [10-12s].

VideoSegmentationDynamicDynamic

The VideoSegmentationDynamicDynamic class configures dynamic segmentation for video based on scene changes.

NameTypeRequiredDescription
min_duration_secintYesThe minimum duration in seconds for each segment.

The platform divides the video into segments that are at least this long. Segments adapt to scene changes and content boundaries and may be longer than the minimum.

Min: 2.
Max: 5.

Example: With min_duration_sec: 3, segments might be: [0-3.2s], [3.2-7.8s], [7.8-12.1s]

Return value

Returns an EmbeddingSuccessResponse object containing the embedding results.

The EmbeddingSuccessResponse class contains the following properties:

NameTypeDescription
dataList[EmbeddingData]Array of embedding results.
usageOptional[EmbeddingUsage]Token counts for the request. Only Marengo 3.5 returns this field. See EmbeddingUsage for details.
metadataOptional[EmbeddingMediaMetadata]Metadata for the media input. Available for the image, text_image, audio, video, and multi_input input types. See EmbeddingMediaMetadata for details.

The EmbeddingData class contains the following properties:

NameTypeDescription
embeddingList[float]The embedding vector for the content.
embedding_uncertaintyOptional[List[float]]A per-dimension uncertainty vector with the same length as the embedding array. A higher value shows lower confidence in that dimension. Present when the request sets embedding_uncertainty: true. Only Marengo 3.5 returns this field.
embedding_optionOptional[EmbeddingDataEmbeddingOption]The modality used to generate this embedding.

Values:
- visual: Embedding based on visual content (a video, a page of a PDF file, or an image embedded asynchronously).
- audio: Embedding based on audio content.
- transcription: Embedding based on transcribed speech. Returned only for content embedded with Marengo 3.0.
- text: The platform does not return this value.
- fused: Embedding based on a combination of the modalities specified in the request. The platform returns this embedding only for video and audio input, and only when the embedding_type parameter includes the fused_embedding value.
- null: For text embeddings and images embedded synchronously.
embedding_scopeOptional[EmbeddingDataEmbeddingScope]The scope for which the embedding was generated.

Values:
- clip: Embedding for a segment. For video and audio input, one embedding per detected segment.
- page: Embedding for one page of a document. The platform returns this value only for PDF files embedded asynchronously.
- asset: Embedding for the entire file. For video and audio input, use this scope for content up to 10-30 seconds to maintain optimal performance.
- null: For text embeddings and images embedded synchronously.
start_secOptional[float]The start time in seconds for this segment. This field is null for text and image embeddings.
end_secOptional[float]The end time in seconds for this segment. This field is null for text and image embeddings.
start_page_numberOptional[int]The first page this embedding covers, counting from 1. The platform returns this field only for page-level embeddings of a PDF file, and null in every other case.
end_page_numberOptional[int]The last page this embedding covers, counting from 1 and including that page. This field matches the start_page_number field when the embedding covers a single page. The platform returns this field only for page-level embeddings of a PDF file, and null in every other case.

EmbeddingUsage

The EmbeddingUsage class provides token counts for the request. Only Marengo 3.5 returns this object.

NameTypeDescription
input_tokensDict[str, int]The number of tokens the request used. Each key names a type of content the request processed, and each value is the token count for that content.
truncatedboolWhether the input was truncated to fit within the token limit.

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.

NameTypeDescription
input_typeLiteral["image"]The type of the input content. Value: image.
input_urlOptional[str]The publicly accessible URL for the image file.
input_filenameOptional[str]The name of the image file.

Text and image: Metadata for text-image embeddings.

NameTypeDescription
input_typeLiteral["text_image"]The type of the input content. Value: text_image.
input_urlOptional[str]The publicly accessible URL for the image file.
input_filenameOptional[str]The name of the image file.

Audio: Metadata for audio embeddings.

NameTypeDescription
input_typeLiteral["audio"]The type of the input content. Value: audio.
input_urlOptional[str]The publicly accessible URL for the audio file.
input_filenameOptional[str]The name of the audio file.
embedding_optionsList[str]The embedding_option values used to generate the embedding.
embedding_scopesList[EmbeddingAudioMetadataEmbeddingScopesItem]The embedding_scope values used to generate the embedding.
durationfloatThe duration of the audio in seconds.
start_offset_secOptional[float]The start offset in seconds.
end_offset_secOptional[float]The end offset in seconds.

Video: Metadata for video embeddings.

NameTypeDescription
input_typeLiteral["video"]The type of the input content. Value: video.
input_urlOptional[str]The publicly accessible URL for the video file.
input_filenameOptional[str]The name of the video file.
clip_lengthOptional[int]Length of each video clip in seconds. Only available for fixed segmentation.
embedding_scopesList[EmbeddingVideoMetadataEmbeddingScopesItem]The embedding_scope values used to generate the embedding.
embedding_optionsList[str]The embedding_option values used to generate the embedding.
durationfloatThe duration of the video in seconds.
start_offset_secOptional[float]The start offset in seconds.
end_offset_secOptional[float]The end offset in seconds.

Multi-input: Metadata for multi-input embeddings.

NameTypeDescription
input_typeLiteral["multi_input"]The type of the input content. Value: multi_input.

API Reference

Create sync embeddings