Create async embeddings
The EmbedClient.V2Client.TasksClient class provides methods to create embeddings asynchronously for audio, video, images, and documents.
Creating embeddings asynchronously requires three steps:
- Create a task using the
createmethod. The platform returns a task ID. - Poll for the status of the task using the
retrievemethod. Wait until the status isready. - Retrieve the embeddings from the response when the status is
readyusing theretrievemethod.
Methods
List embedding tasks
Description: This method returns a list of the async embedding tasks in your account. The platform returns your async embedding tasks sorted by creation date, with the newest at the top of the list.
- Embeddings are stored for seven days.
- When you invoke this method without specifying the
started_atandended_atparameters, the platform returns all the async embedding tasks created within the last seven days.
Function signature and example:
Parameters
Return value
Returns a SyncPager[MediaEmbeddingTask] object that allows you to iterate through the paginated task results.
The SyncPager[T] class contains the following properties and methods:
The MediaEmbeddingTask class contains the following properties:
Each of the four objects above wraps a single metadata field. All four metadata classes inherit the following properties:
VideoEmbeddingMetadata
The VideoEmbeddingMetadata class contains the metadata associated with the embedding.
AudioEmbeddingMetadata
The AudioEmbeddingMetadata class contains the metadata associated with the embedding.
DocumentEmbeddingMetadata
The DocumentEmbeddingMetadata class contains the metadata associated with the embedding. Only Marengo 3.5 returns this object.
ImageEmbeddingMetadata
The ImageEmbeddingMetadata class contains the metadata associated with the embedding. Only Marengo 3.5 returns this object.
API Reference
Create an async embedding task
Description: This method creates embeddings for audio, video, images, and documents asynchronously.
Use this method to embed content at scale, such as long files or the media files you want to make searchable. For a query, or for results you need in the same request, use the Create embeddings class instead.
The content this method accepts depends on the model. Both models embed audio and video. Marengo 3.5 also embeds images and PDF files. For the formats, resolutions, file sizes, and duration limits each model accepts, see the input requirements for Marengo 3.5 or Marengo 3.0.
- Creating a task validates only basic metadata and playability, not the full file. A file can pass this check but still fail later during embedding. When you retrieve the results, check the
statusfield. If it isfailed, theerror.messagefield contains the reason. - This method is rate-limited. With Marengo 3.5, the platform counts input tokens for each type of content. A task can exceed a limit before you see an error. For details, see Input token limits for embedding.
- Embeddings are stored for seven days.
Function signature and example:
Parameters
AsyncAudioInputRequest
The AsyncAudioInputRequest class specifies the configuration for processing audio content. Required when input_type is audio.
AsyncVideoInputRequest
The AsyncVideoInputRequest class specifies the configuration for processing video content. Required when input_type is video.
TimeBasedMetadataEntry
One time-aligned metadata entry. The platform folds the text of the entry into the fused embedding of every segment that overlaps the time range of the entry.
Used by the AsyncAudioInputRequest.time_based_metadata and AsyncVideoInputRequest.time_based_metadata fields. Not applicable to the AsyncDocumentInputRequest class. Requires Marengo 3.5.
AsyncDocumentInputRequest
The AsyncDocumentInputRequest class specifies the configuration for processing documents. Requires Marengo 3.5.
The platform embeds the rendered pages of your PDF file with embedding_option: ["visual"], one embedding per page.
AsyncImageInputRequest
The AsyncImageInputRequest class specifies the configuration for processing image content. Required when input_type is image. Requires Marengo 3.5. The image can be up to 32 MB before encoding, whichever of the three fields you use.
For an image, the embedding_option, embedding_type, and embedding_scope fields each accept a single value; any other value returns a 400 error.
MediaSource
The MediaSource class specifies the source of the media file. Provide exactly one of the following:
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.
AsyncTemporalSegmentation
The AsyncTemporalSegmentation class wraps your settings in a temporal object. Use with Marengo 3.5.
TemporalSegmentation
The TemporalSegmentation type specifies how the platform divides the file into segments. The strategy field selects one variant:
Dynamic segmentation: Creates variable-length segments that align with scene or content boundaries. Use this for content-aware segmentation.
Fixed segmentation: Creates equal-length segments. Use this for consistent timing.
TemporalSegmentationDynamicDynamic
The TemporalSegmentationDynamicDynamic class configures dynamic segmentation. This object is required when strategy is dynamic.
TemporalSegmentationFixedFixed
The TemporalSegmentationFixedFixed class configures fixed segmentation. This object is required when strategy is fixed.
Return value
Returns a TasksCreateResponse object containing the task details.
The TasksCreateResponse class contains the following properties:
API Reference
Create an async embedding task
Related guide
Retrieve task status and results
Description: This method retrieves the status and the results of an async embedding task.
Invoke this method repeatedly until the status field is ready or failed. When the status is ready, use the embeddings from the response. When the status is failed, the error.message field contains the reason.
Embeddings are stored for seven days.
Function signature and example:
Parameters
Return value
Returns an EmbeddingTaskResponse object containing the task status and results.
The EmbeddingTaskResponse 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.
EmbeddingTaskMediaMetadata
The EmbeddingTaskMediaMetadata type provides metadata for the media input. The input_type field selects one variant:
Audio: Metadata for audio embeddings.
Video: Metadata for video embeddings.
Document: Metadata for document embeddings. Only Marengo 3.5 returns this object.
Image: Metadata for image embeddings. Only Marengo 3.5 returns this object.
The EmbeddingTaskResponseError class contains the following property: