Analyze videos

The TwelveLabs Node.js SDK provides methods to analyze videos to generate text from their content.

Titles, topics, and hashtags

This method method has been flattened and is now called client.gist instead of client.generate.gist. The client.generate.gist method will remain available until July 30, 2025; after this date, it will be deprecated. Update your code to use client.gist to ensure uninterrupted service.

Description: This method analyzes a specific video and generates titles, topics, and hashtags based on its content. 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:

1async gist(
2 videoId: string,
3 types: GenerateGistType[],
4 options: RequestOptions = {},
5): Promise<Models.GenerateGistResult>

Parameters:

NameTypeRequiredDescription
videoIdstringYesThe unique identifier of the video for which you want to generate text.
typesGenerateGistType[]YesThe types of text you want to generate. Available values: topics, titles, hashtags.
optionsRequestOptionsNoAdditional options for the request. Defaults to {}.

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 Titles, topics, and hashtags page.

Related guide: Titles, topics, and hashtags.

Summaries, chapters, and highlights

This method method has been flattened and is now called client.summarize instead of client.generate.summarize. The client.generate.summarize method will remain available until July 30, 2025; after this date, it will be deprecated. Update your code to use client.summarize to ensure uninterrupted service.

Description: This method analyzes a video and generates summaries, chapters, or highlights based on its content. Optionally, you can provide a prompt to customize the output.

Function signature and example:

1async summarize(
2 videoId: string,
3 type: GenerateSummarizeType,
4 prompt?: string,
5 temperature?: number,
6 options: RequestOptions = {},
7): Promise<Models.GenerateSummarizeResult>

Parameters:

NameTypeRequiredDescription
videoIdstringYesThe unique identifier of the video for which you want to generate text.
typestringYesThe type of text you want to generate. Available values: summaries, chapters, highlights.
promptstringNoThe prompt to customize the output.
temperaturenumberNoThe temperature to use in the generation.
optionsRequestOptionsNoAdditional options for the request. Defaults to {}.

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 Summaries, chapters, and highlights page.

Related guide: Summaries, chapters, and highlights.

Open-ended analysis

Description: This method analyzes a video and generates text based on its content.

Function signature and example:

1async analyze(
2 videoId: string,
3 prompt: string,
4 temperature?: number,
5 options: RequestOptions = {},
6): Promise<Models.GenerateOpenEndedTextResult>

Parameters:

NameTypeRequiredDescription
videoIdstringYesThe unique identifier of the video you wish to analyze and generate text for.
promptstringYesThe prompt to customize the output.
temperaturenumberNoThe temperature to use in the generation.
optionsRequestOptionsNoAdditional options for the request. Defaults to {}.

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 analysis page.

Related guide: Open-ended analysis.

Open-ended analysis with streaming responses

Description: This method analyzes a video and generates text based on its content. It supports streaming responses.

Function signature and example:

1async analyzStream(
2 { videoId, prompt, temperature }: GenerateTextStreamParams,
3 options: RequestOptions = {},
4): Promise<Models.GenerateTextStreamResult>

Parameters:

NameTypeRequiredDescription
paramsGenerateTextStreamParamsYesParameters for generating open-ended text.
optionsRequestOptionsNoAdditional options for the request. Defaults to {}.

The GenerateTextStreamParams interface defines the parameters for streaming text generated based on video content:

NameTypeRequiredDescription
videoIdstringYesThe unique identifier of the video you wish to analyze and generate text for.
promptstringYesThe prompt to customize the output.
temperaturenumberNoThe temperature to use in the generation.

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

Related guide: Open-ended analysis.

Open-ended text

This method will be deprecated on July 30, 2025. Transition to the analyze method, which provides identical functionality. Ensure you’ve updated your function calls before the deprecation date to ensure uninterrupted service.

Description: This method generates open-ended texts based on your videos.

Function signature and example:

1async text(
2 videoId: string,
3 prompt: string,
4 temperature?: number,
5 options: RequestOptions = {},
6): Promise<Models.GenerateOpenEndedTextResult>

Parameters:

NameTypeRequiredDescription
videoIdstringYesThe unique identifier of the video for which you want to generate text.
promptstringYesThe prompt to customize the output.
temperaturenumberNoThe temperature to use in the generation.
optionsRequestOptionsNoAdditional options for the request. Defaults to {}.

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.

Open-ended text with streaming responses

This method will be deprecated on July 30, 2025. Transition to the analyze method, which provides identical functionality. Ensure you’ve updated your function calls before the deprecation date to ensure uninterrupted service.

Description: This method generates open-ended texts and supports streaming responses.

Function signature and example:

1async textStream(
2 { videoId, prompt, temperature }: GenerateTextStreamParams,
3 options: RequestOptions = {},
4): Promise<Models.GenerateTextStreamResult>

Parameters:

NameTypeRequiredDescription
paramsGenerateTextStreamParamsYesParameters for generating open-ended text.
optionsRequestOptionsNoAdditional options for the request. Defaults to {}.

The GenerateTextStreamParams interface defines the parameters for streaming text generated based on video content:

NameTypeRequiredDescription
videoIdstringYesThe unique identifier of the video for which you want to generate text.
promptstringYesThe prompt to customize the output.
temperaturenumberNoThe temperature to use in the generation.

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

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.