v3

latestOpenAPI 3.1.02026-07-3197486526.1 KB
analyzeAsync > tasks

Create an async analysis task

This method asynchronously analyzes your videos. It supports two analysis modes: general analysis (prompt-based text generation) and video segmentation with custom segment definitions. Video segmentation requires Pegasus 1.5.

<Accordion title="Input requirements"> - Minimum duration: 4 seconds - Maximum duration: 2 hours - Formats: [FFmpeg supported formats](https://ffmpeg.org/ffmpeg-formats.html) - Resolution: 360x360 to 5184x2160 pixels - Aspect ratio: Between 1:1 and 1:2.4, or between 2.4:1 and 1:1. </Accordion>

When to use this method:

  • Generate custom text from your video using a prompt (general analysis)
  • Extract timestamped metadata with custom segment definitions from your video (Pegasus 1.5 only)
  • Analyze videos longer than 1 hour
  • Process videos asynchronously without blocking your application

Do not use this method for:

  • Videos for which you need immediate results or real-time streaming. Use the POST method of the /analyze endpoint instead.

Analyzing videos asynchronously requires three steps:

  1. Create an analysis task using this method. The platform returns a task ID.
  2. Poll the status of the task using the GET method of the /analyze/tasks/{task_id} endpoint. Wait until the status is ready.
  3. Retrieve the results from the response when the status is ready using the GET method of the /analyze/tasks/{task_id} endpoint.

On the Free plan, 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.

<Note title="Note"> This endpoint is rate-limited. For details, see the [Rate limits](/v1.3/docs/get-started/rate-limits) page. </Note>
post/analyze/tasks

Headers

x-api-keystring required

Your API key.

<Note title="Note"> You can find your API key on the <a href="https://playground.twelvelabs.io/dashboard/api-keys" target="_blank">API Keys</a> page. </Note>

Request body

model_name'pegasus1.2' | 'pegasus1.5'

The video understanding model to use for analysis.

  • pegasus1.2: General analysis (prompt-based text generation).
  • pegasus1.5: General analysis (prompt-based text generation) with video clipping, structured prompts with reference images, and video segmentation. See the Pegasus page for token limits.

Default: pegasus1.2

custom_idstring

An optional identifier that you set when you create the task. Use this field to correlate tasks across responses, for example, to distinguish tasks by type or environment.

The platform stores this value unchanged and returns it in the following responses:

  • The GET method of the /analyze/tasks/{task_id} endpoint
  • The GET method of the /analyze/tasks endpoint
  • The analyze.task.ready and analyze.task.failed webhook payloads

Format: 1–64 characters. Alphanumeric, hyphens (-), and underscores (_) only. An empty string is rejected with a 400 Bad Request.

This field does not enforce uniqueness. You can submit multiple tasks with the same custom_id. To prevent duplicate task creation, use an Idempotency-Key header instead.

promptstring

Natural-language instructions for analyzing the video. Required for general analysis (prompt-based text generation). Not supported when analysis_mode is time_based_metadata. To include reference images in your prompt, use the prompt_v2 parameter instead (Pegasus 1.5 only). Mutually exclusive with the prompt_v2 parameter.

Your prompts can be instructive or descriptive, or you can phrase them as questions. Pegasus 1.2 limits prompts to 2,000 tokens. For Pegasus 1.5, this text counts toward the context window.

Examples:

  • Based on this video, I want to generate five keywords for SEO (Search Engine Optimization).
  • I want to generate a description for my video with the following format: Title of the video, followed by a summary in 2-3 sentences, highlighting the main topic, key events, and concluding remarks.
analysis_mode'general' | 'time_based_metadata'

The analysis approach for this task.

  • general: Analyze the video and generate a response based on your prompt. Supports both free-form text and structured output via response_format.
  • time_based_metadata: Segment the video into time-based intervals and extract custom metadata for each segment. Requires model_name set to pegasus1.5 and response_format.type set to segment_definitions.

Default: general

temperaturenumber double

Controls the randomness of the text output.

Default: 0.2 Min: 0 Max: 1

max_tokensinteger

The maximum response length, in tokens. The allowed range depends on the model and analysis mode:

ModelModeMinMaxDefault
Pegasus 1.224,0964096
Pegasus 1.5general51298,3044,096
Pegasus 1.5time_based_metadata2,04898,30432,768
min_segment_durationnumber double

Minimum duration for each extracted segment, in seconds. Set this value to enforce a minimum segment length. Requires model_name set to pegasus1.5 and analysis_mode set to time_based_metadata. Mutually exclusive with response_format.segment_definitions[].time_ranges.

Min: 2

max_segment_durationnumber double

Maximum duration for each extracted segment, in seconds. Set this value to split long continuous sections into shorter segments. Must be greater than or equal to min_segment_duration. Requires model_name set to pegasus1.5 and analysis_mode set to time_based_metadata. Mutually exclusive with response_format.segment_definitions[].time_ranges.

Min: 2

start_timenumber double

Start of the analysis window, as an absolute timestamp in seconds, based on the video's internal metadata. Use with end_time to analyze only a portion of the video. Requires model_name set to pegasus1.5.

<Note title="Notes"> - If omitted, defaults to the video's internal start time. - Most videos start at 0, but some (for example, from cameras or broadcast recordings) may have a non-zero start time. To find the value, run `ffprobe -v error -show_entries format=start_time,duration -of default=noprint_wrappers=1 your_video.mp4`. - Must be less than `end_time` and less than the video duration. The clip (`end_time - start_time`) must be at least `4` seconds. - Mutually exclusive with `response_format.segment_definitions[].time_ranges`. - Together with `end_time`, this parameter determines the billable video duration. If you omit both, billing uses the full video duration. For details, see the [Frequently asked questions](/v1.3/docs/resources/frequently-asked-questions#how-is-video-segmentation-priced) page. </Note>
end_timenumber double

End of the analysis window, as an absolute timestamp in seconds, based on the video's internal metadata. Use with start_time to analyze only a portion of the video. Requires model_name set to pegasus1.5.

<Note title="Notes"> - If omitted, defaults to the video's internal start time plus its duration. - Most videos start at 0, but some (for example, from cameras or broadcast recordings) may have a non-zero start time. To find the value, run `ffprobe -v error -show_entries format=start_time,duration -of default=noprint_wrappers=1 your_video.mp4`. - Must be greater than `start_time` and less than or equal to the video duration. The clip (`end_time - start_time`) must be at least `4` seconds. - Mutually exclusive with `response_format.segment_definitions[].time_ranges`. - Together with `start_time`, this parameter determines the billable video duration. If you omit both, billing uses the full video duration. For details, see the [Frequently asked questions](/v1.3/docs/resources/frequently-asked-questions#how-is-video-segmentation-priced) page. </Note>

Response

Analysis task created successfully.

task_idstring required

The unique identifier of the analysis task.

status'queued' | 'pending' | 'processing' | 'ready' | 'failed' required

The current status of the analysis task.