Skip to navigation

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.

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:

create(
request: TwelvelabsApi.embed.v2.CreateEmbeddingsRequest,
requestOptions?: V2.RequestOptions
): core.HttpResponsePromise<TwelvelabsApi.EmbeddingSuccessResponse>

Parameters

NameTypeRequiredDescription
requestTwelvelabsApi.embed.v2.CreateEmbeddingsRequestYesParameters for creating embeddings.
requestOptionsV2.RequestOptionsNoRequest-specific configuration.

The TwelvelabsApi.embed.v2.CreateEmbeddingsRequest interface contains the following properties:

NameTypeRequiredDescription
inputTypeTwelvelabsApi.embed.v2.CreateEmbeddingsRequestInputTypeYesThe 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 &lt;@name&gt;, where name matches the name field of a media source. Marengo 3.5 accepts images, video, audio, and documents 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.
modelNameTwelvelabsApi.embed.v2.CreateEmbeddingsRequestModelNameYesThe 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.
textTwelvelabsApi.TextInputRequestNoText input configuration. Required when inputType is text. See TextInputRequest for details.
imageTwelvelabsApi.ImageInputRequestNoImage input configuration. Required when inputType is image. See ImageInputRequest for details.
textImageTwelvelabsApi.TextImageInputRequestNoCombined text and image input configuration. Required when inputType is text_image. See TextImageInputRequest for details.
audioTwelvelabsApi.AudioInputRequestNoAudio input configuration. Required when inputType is audio. See AudioInputRequest for details.
videoTwelvelabsApi.VideoInputRequestNoVideo input configuration. Required when inputType is video. See VideoInputRequest for details.
multiInputTwelvelabsApi.MultiInputRequestNoText and media source configuration. Required when inputType is multi_input. See MultiInputRequest for details.
autoTruncatebooleanNoControls the behavior of the platform when the text in your request exceeds 2,000 tokens. Requires Marengo 3.5.
Values:
- false: The platform returns a 400 error.
- true: Truncate your text to fit the limit, and set the usage.truncated field to true in the response.
embeddingUncertaintybooleanNoSet this parameter to true to include a per-dimension uncertainty vector in the data[].embeddingUncertainty field of the response. The vector has the same length as the embedding array. A higher value indicates lower confidence in that dimension. Requires Marengo 3.5.

Requirements:
- Set this parameter to true only for a text-only or media-only request. If you combine text with media sources, the platform returns a 400 error.
- The platform returns a 400 error if your request includes a document, whether PDF, plain text, or Markdown.
embeddingDimensionnumberNoThe number of dimensions for each embedding in the response, including the data[].embeddingUncertainty vector.

Marengo 3.5 produces Matryoshka embeddings: a shorter embedding consists of the first values of the full-length embedding. A 256-dimension embedding, for example, is the first 256 values of a 512-dimension embedding of the same content. Shorter embeddings reduce index size and speed up similarity search; longer embeddings produce higher retrieval quality.

Requirements:
- Requires Marengo 3.5. Setting this parameter when modelName is marengo3.0 returns a 400 error.
- Applies to the entire request: you cannot set it for a single input type or embedding.
- Use the same value across an index.

Default: 512

TextInputRequest

The TwelvelabsApi.TextInputRequest interface specifies the configuration for processing text content. Required when inputType is text.

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

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.

NameTypeRequiredDescription
mediaSourceTwelvelabsApi.MediaSourceYesSpecifies the source of the image file. See MediaSource for details.

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.

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

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.

NameTypeRequiredDescription
mediaSourceTwelvelabsApi.MediaSourceYesSpecifies the source of the audio file. See MediaSource for details.
startSecnumberNoThe 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).
endSecnumberNoThe 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
segmentationTwelvelabsApi.AudioSegmentationNoSpecifies how the platform divides the audio into segments. See AudioSegmentation for details.
embeddingOptionTwelvelabsApi.AudioInputRequestEmbeddingOptionItem[]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"]
embeddingScopeTwelvelabsApi.AudioInputRequestEmbeddingScopeItem[]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"]
embeddingTypeTwelvelabsApi.AudioInputRequestEmbeddingTypeItem[]NoSpecifies how to structure the embedding. Include this parameter only when the embeddingOption parameter contains at least two values.
Values:
- separate_embedding: Returns separate embeddings for each modality specified in the embeddingOption 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 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.

NameTypeRequiredDescription
mediaSourceTwelvelabsApi.MediaSourceYesSpecifies the source of the video file. See MediaSource for details.
startSecnumberNoThe 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)
endSecnumberNoThe 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
segmentationTwelvelabsApi.VideoSegmentationNoSpecifies how the platform divides the video into segments. See VideoSegmentation for details.
embeddingOptionTwelvelabsApi.VideoInputRequestEmbeddingOptionItem[]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"]
embeddingScopeTwelvelabsApi.VideoInputRequestEmbeddingScopeItem[]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"]
embeddingTypeTwelvelabsApi.VideoInputRequestEmbeddingTypeItem[]NoSpecifies how to structure the embedding. Include this parameter only when the embeddingOption parameter contains at least two values.
Values:
- separate_embedding: Returns separate embeddings for each modality specified in the embeddingOption 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.

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.

NameTypeRequiredDescription
inputTextstringNoText to include in the embedding. With Marengo 3.5, the text cannot exceed 2,000 tokens. Use the autoTruncate 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.
mediaSourcesTwelvelabsApi.MultiInputMediaSource[]NoAn array of up to 10 media sources to include in the embedding. Omit it to create a text-only embedding from the inputText field. The platform processes media sources in the order they appear in the array. If you use media source references in the inputText parameter, each must have a corresponding media source with a matching name field. If a reference has no match, the request fails.

MediaSource

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

NameTypeRequiredDescription
base64StringstringNoThe base64-encoded media data. Encoding grows the payload by about a third, so the string you send is larger than the original file.

The maximum size depends on the input type and the model. The description of the field that contains this media source states the limit where it differs; for the formats and sizes each model accepts, see the input requirements for Marengo 3.5 or Marengo 3.0.
urlstringNoThe 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.
assetIdstringNoThe 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, 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.

NameTypeRequiredDescription
namestringNoThe unique identifier for this media source.
This field is required when inputText references this media source.
mediaTypeTwelvelabsApi.MultiInputMediaSourceMediaTypeNoThe 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.
- document: A PDF (.pdf), plain text (.txt), or Markdown (.md) file. Requires Marengo 3.5. For the rules on combining a document with other sources, see MultiInputRequest.
urlstringNoThe publicly accessible URL of the media file. Use direct links to raw files. Media hosting platforms and cloud storage sharing links are not supported.
base64StringstringNoThe base64-encoded media data.
assetIdstringNoThe unique identifier of an asset from a direct or multipart upload.

AudioSegmentation

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

NameTypeRequiredDescription
strategy"fixed"YesThe segmentation strategy. Value: fixed.
fixedTwelvelabsApi.AudioSegmentationFixedYesConfiguration for fixed segmentation.
This object is required when the strategy field is fixed. See AudioSegmentationFixed for details.

AudioSegmentationFixed

The TwelvelabsApi.AudioSegmentationFixed interface configures fixed-length segmentation for audio.

NameTypeRequiredDescription
durationSecnumberYesThe 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 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:

NameTypeRequiredDescription
strategy"fixed"YesThe segmentation strategy. Value: fixed.
fixedTwelvelabsApi.VideoSegmentationFixedFixedYesConfiguration for fixed segmentation. See VideoSegmentationFixedFixed for details.

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

NameTypeRequiredDescription
strategy"dynamic"YesThe segmentation strategy. Value: dynamic.
dynamicTwelvelabsApi.VideoSegmentationDynamicDynamicYesConfiguration for dynamic segmentation. See VideoSegmentationDynamicDynamic for details.

VideoSegmentationFixedFixed

The TwelvelabsApi.VideoSegmentationFixedFixed interface configures fixed-length segmentation for video.

NameTypeRequiredDescription
durationSecnumberYesThe 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 TwelvelabsApi.VideoSegmentationDynamicDynamic interface configures dynamic segmentation for video based on scene changes.

NameTypeRequiredDescription
minDurationSecnumberYesThe 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 HttpResponsePromise that resolves to a TwelvelabsApi.EmbeddingSuccessResponse object containing the embedding results.

The TwelvelabsApi.EmbeddingSuccessResponse interface contains the following properties:

NameTypeDescription
dataTwelvelabsApi.EmbeddingData[]Array of embedding results.
usageTwelvelabsApi.EmbeddingUsageToken counts for the request. Only Marengo 3.5 returns this field. See EmbeddingUsage for details.
metadataTwelvelabsApi.EmbeddingMediaMetadataMetadata for the media input. Available for the image, text_image, audio, video, and multi_input input types. See EmbeddingMediaMetadata for details.

The TwelvelabsApi.EmbeddingData interface contains the following properties:

NameTypeDescription
embeddingnumber[]The embedding vector for the content.
embeddingUncertaintyOptional<number[]>A per-dimension uncertainty vector with the same length as the embedding array. A higher value indicates lower confidence in that dimension. Present when the request sets embeddingUncertainty: true. Only Marengo 3.5 returns this field.
embeddingOptionOptional<TwelvelabsApi.EmbeddingDataEmbeddingOption>The type of the 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: Embedding based on the text content of a PDF, plain text, or Markdown file embedded asynchronously.
- 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 embeddingType parameter includes the fused_embedding value.
- null: For text embeddings and images embedded synchronously.
embeddingScopeOptional<TwelvelabsApi.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 PDF file embedded asynchronously, or for one quadrant of a page when the request sets document.segmentation.spatial.strategy to quadrants. With that strategy, five entries share the same scope and page numbers, so read the quadrant field to tell them apart: the whole-page entry has no quadrant value.
- chunk: Embedding for one chunk of whole sentences of a plain text or Markdown file embedded asynchronously. Read the chunkIndex field for the position of the chunk in the file.
- 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.
startSecOptional<number>The start time in seconds for this segment. This field is null for text and image embeddings.
endSecOptional<number>The end time in seconds for this segment. This field is null for text and image embeddings.
startPageNumberOptional<number>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.
quadrantOptional<string>The quarter of the page this embedding covers. The platform returns this field only when the request sets document.segmentation.spatial.strategy to quadrants, and only on the four quadrant embeddings of a page. This field is null on the whole-page embedding and in every other case.
chunkIndexOptional<number>The position of this chunk in the file, counting from 0. The platform returns this field only on chunk-scope embeddings of a plain text or Markdown file, and null in every other case. Read this field rather than the position of the entry in the data array, which provides no ordering guarantee.
endPageNumberOptional<number>The last page this embedding covers, counting from 1 and including that page. This field matches the startPageNumber 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 TwelvelabsApi.EmbeddingUsage interface contains token counts for the request. Only Marengo 3.5 returns this object.

NameTypeDescription
inputTokensRecord<string, number>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.

The platform reports only the content types your request actually used. The possible keys are video, audio, image, document, and text. Read the keys the response returns rather than assuming a fixed set.
truncatedbooleanWhether the input was truncated to fit within the token limit.

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.

NameTypeDescription
inputType"image"The type of the input content. Value: image.
inputUrlOptional<string>The publicly accessible URL for the image file.
inputFilenameOptional<string>The name of the image file.

Text and image: Metadata for text-image embeddings.

NameTypeDescription
inputType"text_image"The type of the input content. Value: text_image.
inputUrlOptional<string>The publicly accessible URL for the image file.
inputFilenameOptional<string>The name of the image file.

Audio: Metadata for audio embeddings.

NameTypeDescription
inputType"audio"The type of the input content. Value: audio.
inputUrlOptional<string>The publicly accessible URL for the audio file.
inputFilenameOptional<string>The name of the audio file.
embeddingOptionsstring[]The embeddingOption values used to generate the embedding.
embeddingScopesTwelvelabsApi.EmbeddingAudioMetadataEmbeddingScopesItem[]The embeddingScope values used to generate the embedding.
embeddingDimensionOptional<number>The number of dimensions for each embedding in this response. Only Marengo 3.5 returns this field.
durationnumberThe duration of the audio in seconds.
startOffsetSecOptional<number>The start offset in seconds.
endOffsetSecOptional<number>The end offset in seconds.

Video: Metadata for video embeddings.

NameTypeDescription
inputType"video"The type of the input content. Value: video.
inputUrlOptional<string>The publicly accessible URL for the video file.
inputFilenameOptional<string>The name of the video file.
clipLengthOptional<number>Length of each video clip in seconds. Only available for fixed segmentation.
embeddingScopesTwelvelabsApi.EmbeddingVideoMetadataEmbeddingScopesItem[]The embeddingScope values used to generate the embedding.
embeddingDimensionOptional<number>The number of dimensions for each embedding in this response. Only Marengo 3.5 returns this field.
embeddingOptionsstring[]The embeddingOption values used to generate the embedding.
durationnumberThe duration of the video in seconds.
startOffsetSecOptional<number>The start offset in seconds.
endOffsetSecOptional<number>The end offset in seconds.

Multi-input: Metadata for multi-input embeddings.

NameTypeDescription
inputType"multi_input"The type of the input content. Value: multi_input.
embeddingDimensionOptional<number>The number of dimensions for each embedding in this response. Only Marengo 3.5 returns this field.

API Reference

Create sync embeddings