Migrate to Pegasus 1.5
Pegasus 1.5 introduces video segmentation. structured prompts with reference images, video clipping, and per-definition time ranges for segmentation. It supports both general analysis (prompt-based text generation) and video segmentation. Pegasus 1.2 remains available for general analysis only.
Warning
Upgrading the SDK introduces one breaking change: theResponseFormat type has been split into SyncResponseFormat and AsyncResponseFormat. If you use structured responses, update your imports before upgrading. See Update the ResponseFormat type for details.Except for the breaking change mentioned above, your existing code continues to work after upgrading. TwelveLabs recommends migrating to Pegasus 1.5 to access the new features.
Migration steps
Update the ResponseFormat type
If you use structured responses, the ResponseFormat type has been split into SyncResponseFormat (for sync analysis) and AsyncResponseFormat (for async analysis).
Before:
After (sync):
Update your analyze calls
Make the following changes to your sync or async analyze calls:
- Set
model_nameto"pegasus1.5". If you omit this parameter, the platform uses Pegasus 1.2 by default. - Replace the
promptstring parameter withprompt_v2, a structured object. Setinput_textto your prompt text. To include reference images, addmedia_sources.
The parameter names and usage are the same for both sync and async methods.
Before:
After:
Note
Pegasus 1.5 supports up to 65,536 tokens (compared to 4,096 for Pegasus 1.2). If your application validates or capsmax_tokens, update the boundary.Explore new capabilities
Pegasus 1.5 introduces the following capabilities that are not available in Pegasus 1.2.
Video clipping
Analyze a specific portion of a video using 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:
Structured prompts with reference images
Reference up to 4 images in your prompt using the prompt_v_2 parameter. 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 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:
Per-definition time ranges for segmentation
Restrict segment extraction to specific time windows within the video. Add the time_ranges parameter to individual segment definitions. The following example limits scene detection to two specific time windows (0–30s and 60–90s):