Titles, topics, and hashtags

Use the /gist endpoint if you require a swift breakdown of the essence of your videos. This endpoint operates exclusively on a set of predefined formats to generate the following:

  • Title: Distills the essence of a video into a brief, coherent phrase, facilitating quick understanding and categorization. For example, a title like "From Consumerism to Minimalism: A Journey Toward Sustainable Living" clearly indicates the video's narrative trajectory, emphasizing themes related to consumption patterns and sustainable lifestyles.
  • Topic: Represents the central themes or subjects of a video and provides a high-level understanding based on the meaning conveyed by all modalities. Topics enable effective categorization and quick referencing. For example, "Shopping Vlog Lifestyle" denotes a video covering aspects related to shopping experiences, vlogging, and the associated lifestyle.
  • Hashtag: Concisely summarizes the themes, subjects, or sentiments expressed within a video. Hashtags improve categorization and searchability on social media platforms. For example, hashtags such as #BlackFriday, #ShoppingMania, and #Consumerism indicate key focal points in a video, potentially related to shopping events, consumer behaviors, or broader commentary on consumption patterns.

For a description of each field in the request and response, see theAPI Reference > Generate titles, topics, or hashtags page.

Depending on your needs, you can generate either a single type of text or multiple types simultaneously with a single API call. Refer to the examples provided below for guidance.

Prerequisites

The examples in this guide assume the following:

  • You’re familiar with the concepts that are described on the Platform overview page.
  • You’ve already created an index, and the Pegasus video understanding engine is enabled for this index..
  • You've uploaded a video, and the platform has finished indexing it.

Generate a title

To generate a title based on the content of a video, invoke the gist method of the generate object with the following parameters:

  • video_id: A string representing the unique identifier of the video for which you want to generate a title.
  • types: An array of strings representing the type of text you want to generate . This example uses ["title"].
from twelvelabs import TwelveLabs

client = TwelveLabs(api_key="<YOUR_API_KEY>")

gist = client.generate.gist(
  video_id="<YOUR_VIDEO_ID>",
  types=["title"]
)
print(f"Title={gist.title}")
import { TwelveLabs } from 'twelvelabs-js';

const client = new TwelveLabs({ apiKey: '<YOUR_API_KEY>'});

const gist = await client.generate.gist('<YOUR_VIDEO_ID>', ['title']);
console.log(`Title: ${gist.title}`);

The output should look similar to the following one:

Title=A Day in My Life: Graduation, Moving Home, Shopping Hauls, Cooking, and Outdoor Adventures!

Generate a title, topic, and hashtag

To generate a title, topic, and hashtag based on the content of a video, invoke the gist method of the generate object with the following parameters:

  • video_id: A string representing the unique identifier of the video for which you want to generate a title.
  • types: An array of strings representing the types of text you want to generate. This example uses ["title", "topic", "hashtag"].
from twelvelabs import TwelveLabs

client = TwelveLabs(api_key="<YOUR_API_KEY>")

gist = client.generate.gist(
  video_id="<YOUR_VIDEO_ID>",
  types=["title", "topic", "hashtag"]
)
print(f"Title={gist.title}\nTopic={gist.topics}\nHashtags={gist.hashtags}")
import { TwelveLabs, SearchData } from 'twelvelabs-js';

const client = new TwelveLabs({ apiKey: '<YOUR_API_KEY>'});

const gist = await client.generate.gist('<YOUR_VIDEO_ID>', ['title', 'topic', 'hashtag']);
console.log(`Title: ${gist.title}\nTopics=${gist.topics}\nHashtags=${gist.hashtags}`);

The output should look similar to the following one:

Title=A Day in My Life: Graduation, Moving Home, Shopping Hauls, Cooking, and 
Outdoor Adventures!
Topic=["Lifestyle Vlog"]
Hashtags=["graduation", "moving", "home", "shopping", "hauls", "cooking", "outdoor", 
"adventures", "lifestyle", "vlog"]