Generate text from video
The Resources.Generate
class provides methods to generate various types of text content from videos.
Titles, topics, and hashtags
Description: This method generates titles, topics, and hashtags for a specific video. It uses predefined formats and doesn’t require a custom prompt, and it’s best for generating immediate and straightforward text representations without specific customization.
Function signature and example:
Parameters:
Return value: Returns a Promise
that resolves to a Models.GenerateGistResult
instance.
API Reference: For a description of each field in the request and response, see the Generate topics, titles, and hashtags page.
Related guide: Titles, topics, and hashtags.
Summaries, chapters, and highlights
Description: This method generates summaries, chapters, or highlights for your videos. Optionally, you can provide a prompt to customize the output.
Function signature and example:
Parameters:
Return value: Returns a Promise
that resolves to a Models.GenerateSummarizeResult
instance.
API Reference: For a description of each field in the request and response, see the Generate summaries, chapters, and highlights page.
Related guide: Summaries, chapters, and highlights.
Open-ended text
Description: This method generates open-ended texts based on your videos.
Function signature and example:
Parameters:
Return value: Returns a Promise
that resolves to a Models.GenerateOpenEndedTextResult
instance.
API Reference: For a description of each field in the request and response, see the Open-ended text page.
Related guide: Open-ended text .
Open-ended text with streaming responses
Description: This method generates open-ended texts and supports streaming responses.
Function signature and example:
Parameters:
The GenerateTextStreamParams
interface defines the parameters for streaming text generated based on video content:
API Reference: For a description of each field in the request and response, see the Open-ended text page.
Related guide: Streaming responses.
Error codes
This section lists the most common error messages you may encounter while using the Resources.Generate
class.
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.