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:
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.
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.
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.
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.
Replace ResponseFormat with SyncResponseFormat.
Before:
After:
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.
model_name parameter and set it to "pegasus1.5". If you omit this parameter, the platform uses Pegasus 1.2 by default.prompt parameter with prompt_v_2. This parameter is now an object. Set the input_text field to your prompt text.prompt parameter, but it will be deprecated in a future version. TwelveLabs recommends that you replace it with prompt_v_2.Before:
After:
max_tokens, update the limit.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.
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
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
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 the 30-second mark: