Create async embeddings
The Embed.V2.Tasks interface 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
The TwelvelabsApi.embed.v2.TasksListRequest interface contains the following properties:
Return value
Returns a Promise that resolves to a Page<TwelvelabsApi.MediaEmbeddingTask> object that allows you to iterate through the paginated task results.
The Page<T> class contains the following properties and methods:
The TwelvelabsApi.MediaEmbeddingTask interface contains the following properties:
Each of the four objects above wraps a single metadata field. All four metadata interfaces extend TwelvelabsApi.BaseEmbeddingMetadata, which contributes the following properties:
VideoEmbeddingMetadata
The TwelvelabsApi.VideoEmbeddingMetadata interface contains the metadata associated with the embedding.
AudioEmbeddingMetadata
The TwelvelabsApi.AudioEmbeddingMetadata interface contains the metadata associated with the embedding.
DocumentEmbeddingMetadata
The TwelvelabsApi.DocumentEmbeddingMetadata interface contains the metadata associated with the embedding. Only Marengo 3.5 returns this object.
ImageEmbeddingMetadata
The TwelvelabsApi.ImageEmbeddingMetadata interface 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 interface 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
The TwelvelabsApi.embed.v2.CreateAsyncEmbeddingRequest interface contains the following properties:
AsyncAudioInputRequest
The TwelvelabsApi.AsyncAudioInputRequest interface specifies the configuration for processing audio content. Required when inputType is audio.
AsyncVideoInputRequest
The TwelvelabsApi.AsyncVideoInputRequest interface specifies the configuration for processing video content. Required when inputType 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.timeBasedMetadata and AsyncVideoInputRequest.timeBasedMetadata fields. Not applicable to the AsyncDocumentInputRequest interface. Requires Marengo 3.5.
AsyncDocumentInputRequest
The TwelvelabsApi.AsyncDocumentInputRequest interface specifies the configuration for processing documents. Requires Marengo 3.5.
The platform embeds the rendered pages of your PDF file with embeddingOption: ["visual"], one embedding per page.
AsyncImageInputRequest
The TwelvelabsApi.AsyncImageInputRequest interface specifies the configuration for processing image content. Required when inputType 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 embeddingOption, embeddingType, and embeddingScope fields each accept a single value; any other value returns a 400 error.
MediaSource
The TwelvelabsApi.MediaSource interface specifies the source of the media file. Provide exactly one of the following:
AudioSegmentation
The TwelvelabsApi.AudioSegmentation interface specifies how the platform divides the audio into segments using fixed-length intervals.
AudioSegmentationFixed
The TwelvelabsApi.AudioSegmentationFixed interface configures fixed-length segmentation for audio.
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:
Dynamic segmentation: Divides the video into adaptive segments based on scene changes:
VideoSegmentationFixedFixed
The TwelvelabsApi.VideoSegmentationFixedFixed interface configures fixed-length segmentation for video.
VideoSegmentationDynamicDynamic
The TwelvelabsApi.VideoSegmentationDynamicDynamic interface configures dynamic segmentation for video based on scene changes.
AsyncTemporalSegmentation
The TwelvelabsApi.AsyncTemporalSegmentation interface wraps your settings in a temporal object. Use with Marengo 3.5.
TemporalSegmentation
The TwelvelabsApi.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 TwelvelabsApi.TemporalSegmentationDynamicDynamic interface configures dynamic segmentation. This object is required when strategy is dynamic.
TemporalSegmentationFixedFixed
The TwelvelabsApi.TemporalSegmentationFixedFixed interface configures fixed segmentation. This object is required when strategy is fixed.
Return value
Returns an HttpResponsePromise that resolves to a TwelvelabsApi.embed.v2.TasksCreateResponse object containing the task details.
The TwelvelabsApi.embed.v2.TasksCreateResponse interface 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.
Function signature and example:
Parameters
Return value
Returns an HttpResponsePromise that resolves to a TwelvelabsApi.EmbeddingTaskResponse object containing the task status and results.
The TwelvelabsApi.EmbeddingTaskResponse interface contains the following properties:
The TwelvelabsApi.EmbeddingData interface contains the following properties:
EmbeddingUsage
The TwelvelabsApi.EmbeddingUsage interface contains token counts for the request. Only Marengo 3.5 returns this object.
EmbeddingTaskMediaMetadata
The TwelvelabsApi.EmbeddingTaskMediaMetadata type provides metadata for the media input. The inputType 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 TwelvelabsApi.EmbeddingTaskResponseError interface contains the following property: