Use the TwelveLabs Pegasus 1.2 model to analyze videos and generate text based on their content.
Pegasus 1.2 is available in the following regions:
Amazon Bedrock offers the following cross-region inference options:
For details, see the Global cross-Region inference and Geographic cross-Region inference pages in the Amazon Bedrock documentation.
For details on pricing, see the Amazon Bedrock pricing page.
Before you start, ensure you have the following:
boto3 library.Pegasus supports base64 encoded strings and S3 URIs for video input. The base64 method has a 36MB file size limit. This guide uses S3 URIs.
Your S3 bucket and the model must be in the same region. If regions don’t match, the API returns a ValidationException error.
You use the InvokeModel API to analyze videos and generate text. This API processes your request synchronously and returns the generated text directly in the response.
The InvokeModel API requires two parameters:
modelId: The inference profile ID for the model.body: A JSON-encoded string containing your input parameters.The body contains:
inputPrompt: A string that guides the model on the desired format or contentmediaSource: The video source, which contains either:
base64String: Your base64-encoded video for inline processings3Location: The S3 location for videos stored in S3The example code below demonstrates how to use Pegasus to analyze videos and generate text based on their content.
Ensure you replace the following placeholders with your values:
<YOUR_REGION>: with your region (example: “eu-west-1”).<INFERENCE_PROFILE_ID>: with the inference profile ID. See the Model specifications section for available inference profile IDs.<YOUR_ACCOUNT_ID>: with your AWS account ID (example: “123456789012”).<YOUR_BUCKET_NAME>: with the name of your S3 bucket (example: “my-video-bucket”).<YOUR_VIDEO_FILE>: with the name of your video file (example: “my_video.mp4”).<YOUR_PROMPT>: with a string that guides the model on the desired format or content (example: “Summarize this video”).After generating text from your videos, you can integrate the output into various applications and workflows.
The typical workflow is as follows:
You can use Pegasus-generated text to:
For a complete list of request parameters and response fields, see the TwelveLabs Pegasus 1.2 page in the Amazon Bedrock documentation.