Create async embeddings
The EmbedClient.V2Client.TasksClient class provides methods to create embeddings asynchronously for audio and video content. Use this class for processing files longer than 10 minutes.
Note
This class only supports Marengo version 3.0 or newer.
When to use this class:
- Process audio or video files longer than 10 minutes
- Process files up to 4 hours in duration
Input requirements
Video:
- Minimum duration: 4 seconds
- Maximum duration: 4 hours
- Maximum file size: 4 GB
- Formats: FFmpeg supported formats
- Resolution: 360x360 to 3840x2160 pixels
- Aspect ratio: Between 1:1 and 1:2.4, or between 2.4:1 and 1:1
Audio:
- Minimum duration: 4 seconds
- Maximum duration: 4 hours
- Maximum file size: 2 GB
- Formats: WAV (uncompressed), MP3 (lossy), FLAC (lossless)
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.
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:
API Reference: List async embedding tasks
Create an async embedding task
Description: This method creates embeddings for audio and video content asynchronously.
Function signature and example:
Parameters:
AudioInputRequest
The AudioInputRequest class specifies configuration for processing audio content. Required when input_type is audio.
VideoInputRequest
The VideoInputRequest class specifies configuration for processing video content. Required when input_type is video.
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.
Return value: Returns a TasksCreateResponse object containing the task details.
The TasksCreateResponse class contains the following properties:
API Reference: Create an async embedding task
Retrieve task status and results
Description: This method retrieves the status and the results of an async embedding task.
Task statuses:
processing: The platform is creating the embeddings.ready: Processing is complete. Embeddings are available in the response.failed: The task failed. Embeddings were not created.
Invoke this method repeatedly until the status field is ready. When status is ready, use the embeddings from the response.
Function signature and example:
Parameters:
Return value: Returns an EmbeddingTaskResponse object containing the task status and results.
The EmbeddingTaskResponse class contains the following properties:
For details about the EmbeddingData class, see the Create an async embedding task section.
API Reference: Retrieve task status and results