Migrate from Pegasus 1.2 to Pegasus 1.5
This guide shows how to migrate your application to Pegasus 1.5. It focuses on SDK migrations, but it also includes cURL examples for steps where the request shape changes.
Pegasus 1.5 adds the following capabilities over Pegasus 1.2:
- Video segmentation with structured, timestamped output, including per-definition time ranges
- Structured prompts with up to 4 reference images
- Video clipping to analyze specific time ranges
- Responses up to 98,304 tokens (up from 4,096) within a shared context window
Pegasus 1.2 remains available for general analysis only.
To use Pegasus 1.5, update your SDK to the latest version, or update your REST API calls as shown in the cURL examples. If you use structured responses, you may also need to update your response format types. See the Update the ResponseFormat type section for details.
Migration steps
Replace video_id with the video parameter
Skip this step if you already use the video parameter.
Pegasus 1.5 no longer supports the video_id parameter. If you use sync analysis, upload your video as an asset and pass the asset ID through the video parameter instead. The async analysis endpoint already requires the video parameter, so no changes are needed. For a complete walkthrough, see the Analyze videos guide.
Python
Node.js
cURL
Replace the video_id parameter with a VideoContext_AssetId object passed to the video parameter.
Before:
After:
To find the asset ID for a video you uploaded with the Create a video indexing task method, call the Retrieve video information method. The response includes the asset_id field.
Update the ResponseFormat type
Skip this step if you do not use structured responses.
The ResponseFormat type has been split into SyncResponseFormat for synchronous analysis and AsyncResponseFormat for asynchronous analysis.
The examples below show how to update your code for sync analysis. For async analysis, make similar changes and replace ResponseFormat with AsyncResponseFormat.
Python
Node.js
Replace ResponseFormat with SyncResponseFormat.
Before:
After:
Update your analysis calls
These changes apply to both sync and async methods. The examples below show how to update your code for sync analysis. For async analysis, make similar changes.
Python
Node.js
cURL
- Add the optional
model_nameparameter and set it to"pegasus1.5". If you omit this parameter, the platform uses Pegasus 1.2 by default. - Replace the
promptparameter withprompt_v_2. This parameter is now an object. Set theinput_textfield to your prompt text.
Note
You can still use theprompt parameter, but it will be deprecated in a future version. TwelveLabs recommends that you replace it with prompt_v_2.Before:
After:
Note
Pegasus 1.5 supports responses up to 98,304 tokens, compared to 4,096 for Pegasus 1.2. The input and response must fit within the context window. If your application validates or caps the maximum response length, update the limit.Use new Pegasus 1.5 features
The following examples show each new capability.
Video segmentation
Pegasus 1.5 transforms raw videos into structured, timestamped data. Define the types of segments you want to detect and the custom fields you want to extract. Video segmentation requires the asynchronous analysis endpoint.
Python
Node.js
cURL
The following example detects scene changes and extracts a sentiment field for each segment:
You can also restrict segment extraction to specific time windows. Add the time_ranges parameter to individual segment definitions. The following example limits scene detection to two windows (0-30s and 60-90s):
Structured prompts with reference images
Python
Node.js
cURL
Reference up to 4 images in your prompt using prompt_v_2. Use <@name> placeholders in the prompt text and declare the images in media_sources. The following example asks whether a reference photo matches a person in the video:
Video clipping
Python
Node.js
cURL
Analyze a specific portion of a video with the start_time and end_time parameters. The clip must be at least 4 seconds long. The following example analyzes a 60-second clip starting at timestamp 30: