Analyze videos
The TwelveLabs Node.js SDK provides methods to analyze videos to generate text from their content.
Titles, topics, and hashtags
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:
Parameters:
The GistRequest
interface contains the following properties:
Return value: Returns an HttpResponsePromise
that resolves to a TwelvelabsApi.Gist
instance.
The Gist
interface contains the following properties:
The TokenUsage
interface contains the following properties:
API Reference: Titles, topics, and hashtags page.
Related guide: Titles, topics, and hashtags.
Summaries, chapters, and highlights
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:
Parameters:
The SummarizeRequest
interface contains the following properties:
Return value: Returns a Promise
that resolves to a SummarizeResponse
object containing the generated content. The response type varies based on the type
parameter.
When type
is "summary"
- Returns a SummarizeResponse.Summary
object with the following properties:
When type
is "chapter"
- Returns a SummarizeResponse.Chapter
object with the following properties:
When type
is "highlight"
- Returns a SummarizeResponse.Highlight
object with the following properties:
The SummarizeChapterResultChaptersItem
interface contains the following properties:
The SummarizeHighlightResultHighlightsItem
interface contains the following properties:
The TokenUsage
interface contains the following properties:
API Reference: Summaries, chapters, and highlights.
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:
Parameters:
The AnalyzeRequest
class contains the following properties:
Return value: Returns a Promise
that resolves to a NonStreamAnalyzeResponse
object containing the generated text.
The NonStreamAnalyzeResponse
interface contains the following properties:
The TokenUsage
interface contains the following properties:
API Reference: 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.
Function signature and example:
Parameters:
The AnalyzeStreamRequest
class contains the following properties:
Return value: Returns a Promise
that resolves to a Stream<StreamAnalyzeResponse>
object that can be iterated over to receive streaming text chunks.
The StreamAnalyzeResponse
can be either a StreamStartResponse
, a StreamTextResponse
, or a StreamEndResponse
.
The StreamStartResponse
interface contains the following properties:
The StreamTextResponse
interface contains the following properties:
The StreamEndResponse
interface contains the following properties:
The StreamStartResponseMetadata
interface contains the following properties:
The StreamEndResponseMetadata
interface contains the following properties:
The TokenUsage
interface contains the following properties:
API Reference: Open-ended analysis page.
Related guide: Open-ended analysis.
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.