Analyze videos
The TwelveLabs Python SDK provides methods to analyze videos and generate text from their content.
Methods
Open-ended analysis
Description: This method analyzes a video and generates text based on its content.
Note
This method is rate-limited. For details, see the Rate limits page.
Function signature and example:
Parameters
The ResponseFormat class contains the following properties:
Return value
Returns a NonStreamAnalyzeResponse object containing the generated text.
The NonStreamAnalyzeResponse class contains the following properties:
The TokenUsage class contains the following properties:
The maximum length of the response is 4,096 tokens.
API Reference
Related guide
Open-ended analysis with streaming responses
Description: This method analyzes a video and generates open-ended text based on its content.
Note
This method is rate-limited. For details, see the Rate limits page.
Function signature and example:
Parameters
The ResponseFormat class contains the following properties:
Return value
Returns an iterator of StreamAnalyzeResponse objects. Each response can be a StreamAnalyzeResponse_StreamStart, StreamAnalyzeResponse_TextGeneration, or StreamAnalyzeResponse_StreamEnd.
The StreamAnalyzeResponse_StreamStart class contains the following properties:
The StreamAnalyzeResponse_TextGeneration class contains the following properties:
The StreamAnalyzeResponse_StreamEnd class contains the following properties:
The StreamStartResponseMetadata class contains the following properties:
The StreamEndResponseMetadata class contains the following properties:
The TokenUsage class contains the following properties:
The maximum length of the response is 4,096 tokens.
API Reference
Related guide
Error codes
This section lists the most common error messages you may encounter while analyzing videos.
token_limit_exceeded- Your request could not be processed due to exceeding maximum token limit. Please try with another request or another video with shorter duration.
index_not_supported_for_generate- You can only summarize videos uploaded to an index with an engine from the Pegasus family enabled.