Async analysis
The AnalyzeAsync.Tasks interface provides methods to analyze videos or images asynchronously, generate text, and extract structured, timestamped segments. Each request must contain a video or one or more images, but not both.
The platform supports two analysis modes:
- General analysis: Prompt-based text generation with a video or one or more images.
- Video segmentation: Timestamped metadata with custom segment definitions.
When to use this interface:
- Generate custom text from your video or one or more images using a prompt (general analysis)
- Extract timestamped metadata with custom segment definitions from your video
- Analyze videos longer than 1 hour, or a portion of a video up to 4 hours long
- Process videos or images asynchronously without blocking your application
Do not use this interface for:
- Videos or images for which you need immediate results or real-time streaming. Use the
analyzemethod instead.
Input requirements
Videos
- The video can be up to 2 hours long, or up to 4 hours when you analyze only a portion of it. You can analyze between 1 second and 2 hours of the video. HLS and base64 videos are limited to 2 hours.
- Formats: FFmpeg supported formats
- Resolution: 360x360 to 5184x2160 pixels
- Aspect ratio: Between 1:1 and 1:2.4, or between 2.4:1 and 1:1
Images
- You can provide one to twenty images per request.
- Formats: JPEG, PNG, WebP, GIF, and BMP.
- Maximum size: 20 MB per image.
- Maximum pixel count: 16,777,216 pixels per image (width × height).
In legacy billing, on the Free plan, analysis hours count toward a shared limit that also covers indexing - the number of segment definitions does not affect this limit. On paid plans, you pay based on how much video you process and how many segment definitions you include - see the Frequently asked questions page for examples. In the new billing, the allowances of your plan apply. See Plans, allowances, and overage.
Analyzing content asynchronously requires three steps:
- Create an analysis task using the
createmethod. The platform returns a task identifier. - Poll the status of the task using the
retrievemethod. Wait until the status isready,failed, orcanceled. - When the status is
ready, retrieve the results using theretrievemethod.
Methods
List analysis tasks
Description: This method returns a list of the analysis tasks in your account. The platform returns your analysis tasks sorted by creation date, with the newest at the top of the list.
Function signature and example:
Parameters:
The TwelvelabsApi.analyzeAsync.TasksListRequest interface has the following properties:
Return value: Returns an HttpResponsePromise that resolves to a TwelvelabsApi.analyzeAsync.TasksListResponse object.
The TwelvelabsApi.analyzeAsync.TasksListResponse interface contains the following properties:
The TwelvelabsApi.PageInfo interface contains the following properties:
For details about AnalyzeTaskResponse, see Retrieve task status and results.
API Reference: List async analysis tasks
Create an async analysis task
Description: This method analyzes a video or one or more images asynchronously. Each request must contain a video or one or more images, but not both.
The method supports two analysis modes:
- General analysis: Prompt-based text generation with a video or one or more images.
- Video segmentation: Timestamped metadata with custom segment definitions.
On the Free plan in legacy billing, you have a total of 600 minutes (10 hours) shared across indexing, analysis, and segmentation. For details, see the Video hours and video count limits section. In the new billing, the allowances of your plan apply in place of this limit. See Plans, allowances, and overage.
This method is rate-limited. For details, see the Rate limits page.
Function signature and example:
Parameters:
The TwelvelabsApi.analyzeAsync.CreateAsyncAnalyzeRequest interface has the following properties:
VideoContext
The TwelvelabsApi.VideoContext type specifies the source of the video. Provide exactly one of the following. Mutually exclusive with the image parameter.
Set the type discriminator field to "url", "asset_id", or "base64_string" to indicate which source you are providing.
AnalyzeImageInput
The TwelvelabsApi.AnalyzeImageInput interface defines an image to analyze. Provide exactly one of url, assetId, or base64String.
The AsyncResponseFormat class contains the following properties:
AnalyzePromptV2
The AnalyzePromptV2 interface defines a structured prompt that uses <@name> placeholders to reference images. Mutually exclusive with the prompt and image parameters.
SegmentDefinition
The TwelvelabsApi.SegmentDefinition interface defines a type of segment to extract from the video.
SegmentField
The TwelvelabsApi.SegmentField interface defines a custom field to extract for each segment.
SegmentFieldItems
The TwelvelabsApi.SegmentFieldItems interface defines the per-item structure of a segment field whose type is array or time_array. For an array field, the type value specifies the scalar element type. For a time_array field, use object as the type value and declare the fields of each event in the fields array.
TimeArrayItemField
The TwelvelabsApi.TimeArrayItemField interface defines a field inside a time_array item. The platform adds start_time and end_time keys to every event automatically. You cannot declare fields with these names. A time_array field cannot contain another time_array field. The format property is not accepted on per-event fields.
SmeMediaSource
The TwelvelabsApi.SmeMediaSource interface defines a reference image that provides visual context for segment identification. Provide exactly one of url, assetId, or base64String.
Return value: Returns an HttpResponsePromise that resolves to a TwelvelabsApi.CreateAnalyzeTaskResponse object containing the task details.
The TwelvelabsApi.CreateAnalyzeTaskResponse interface contains the following properties:
API Reference: Create an async analysis task
Retrieve task status and results
Description: This method retrieves the status and results of an analysis task.
Task statuses:
queued: The task is waiting to be processed.pending: The task is queued and waiting to start.processing: The platform is analyzing the video.ready: Processing is complete. Results are available in the response.failed: The task failed. No result is available. Theerrorfield describes the failure.canceled: The task was canceled. No result is available. Theerrorfield describes the cancellation reason, if available.
The ready, failed, and canceled statuses are final.
Poll this method until status is ready, failed, or canceled. When status is ready, use the results from the response.
Function signature and example:
Parameters:
Return value: Returns an HttpResponsePromise that resolves to a TwelvelabsApi.AnalyzeTaskResponse object containing the task status and results.
The TwelvelabsApi.AnalyzeTaskResponse interface contains the following properties:
The TwelvelabsApi.AnalyzeTaskResponseVideoSource interface contains the following properties:
The TwelvelabsApi.AnalyzeTaskResponseVideoSourceSystemMetadata interface contains the following properties:
The TwelvelabsApi.AnalyzeTaskResponseRequestParams interface contains the following properties:
The TwelvelabsApi.AnalyzeTaskMediaSource interface contains the following properties:
The TwelvelabsApi.AnalyzeTaskResponseRequestParamsResponseFormat interface contains the following properties:
The TwelvelabsApi.AnalyzeTaskResult interface contains the following properties:
The TwelvelabsApi.AnalyzeTaskResultUsage interface contains the following properties:
The TwelvelabsApi.AnalyzeTaskError interface contains the following properties:
API Reference: Retrieve analysis task status and results
Cancel an async analysis task
Description: Use this method to cancel an asynchronous analysis task in your account. To cancel a task created as part of a batch, use the analyzeAsync.batches.cancel method.
You can cancel a task with the queued, pending, or processing status. This action cannot be undone.
Processing that has already started can continue briefly after cancellation.
When you cancel a task, the platform can send an analyze.task.canceled webhook. Delivery is best-effort: a 200 response is not a delivery guarantee. When you receive the event, retrieve the task for its current state.
Function signature and example:
Parameters:
Return value: Returns an HttpResponsePromise that resolves to a TwelvelabsApi.CancelAnalyzeTaskResponse containing taskId and the final status canceled. This response is also returned when the task was canceled by a previous request.
API Reference: Cancel an async analysis task
Delete an analysis task
Description: This method deletes an analysis task. You can only delete tasks that are not currently being processed.
Function signature and example:
Parameters:
Return value: Returns an HttpResponsePromise that resolves to void. If successful, the platform returns a 204 No Content response.
API Reference: Delete an analysis task