Generate text from video

The resources.Generate class provides methods to generate various types of text content from videos.

Related quickstart notebook

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:

1def gist(
2 self,
3 video_id: str,
4 types: List[Union[str, Literal["topic", "hashtag", "title"]]],
5 **kwargs
6) -> models.GenerateGistResult

Parameters:

NameTypeRequiredDescription
video_idstrYesThe unique identifier of the video for which you want to generate text.
typesList[Union[str, Literal["topic", "hashtag", "title"]]]YesThe types of text you want to generate. Available values: topics, titles, hashtags.
**kwargsdictNoAdditional keyword arguments for the request.

Return value: Returns a models.GenerateGistResult object containing the generated gist elements.

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:

1def summarize(
2 self,
3 video_id: str,
4 type: Union[str, Literal["summary", "chapter", "highlight"]],
5 *,
6 prompt: Optional[str] = None,
7 temperature: Optional[float] = None,
8 **kwargs
9) -> models.GenerateSummarizeResult

Parameters:

NameTypeRequiredDescription
video_idstringYesThe unique identifier of the video for which you want to generate text.
typeUnion[str, Literal["summary", "chapter", "highlight"]YesThe type of text you want to generate. Available values: summaries, chapters, highlights.
promptOptional[str]NoThe prompt to customize the output.
temperatureOptional[float]NoThe temperature to use in the generation.
**kwargsRequestOptionsNoAdditional keyword arguments for the request.

Return value: Returns a models.GenerateSummarizeResult object containing the generated content.

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:

1def text(
2 self,
3 video_id: str,
4 prompt: str,
5 *,
6 temperature: Optional[float] = None,
7 **kwargs
8) -> models.GenerateOpenEndedTextResult

Parameters:

NameTypeRequiredDescription
video_idstrYesThe unique identifier of the video for which you want to generate text.
promptstrYesThe prompt to customize the output.
temperatureOptional[float]NoThe temperature to use in the generation.
**kwargsdictNoAdditional keyword arguments for the request.

Return value: Returns a models.GenerateOpenEndedTextResult object containing the generated text.

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:

1def text_stream(
2 self,
3 video_id: str,
4 prompt: str,
5 *,
6 temperature: Optional[float] = None,
7 **kwargs
8) -> models.GenerateOpenEndedTextStreamResult

Parameters:

NameTypeRequiredDescription
video_idstrYesThe unique identifier of the video for which you want to generate text.
promptstrNoThe prompt to customize the output.
temperatureOptional[float]NoThe temperature to use in the generation.
**kwargsdictNoAdditional keyword arguments for the request.

Return value: Returns a models.GenerateOpenEndedTextStreamResult object.

API Reference: For a description of each field in the request and response, see the Open-ended text page.

Related guide: Streaming responses .

Built with