Typical workflows
This page provides an overview of common workflows for using the TwelveLabs JavaScript SDK. Each workflow consists of a series of steps, with links to detailed documentation for each step.
All workflows involving uploading video content to the platform require asynchronous processing. You must wait for the video processing to complete before proceeding with the subsequent steps.
Prerequisites
Ensure that the following prerequisites are met before using the JavaScript SDK:
- Node.js 14 or newer must be installed on your machine.
- You have an API key. If you don’t have an account, please sign up for a free account. Then, to retrieve your API key, go to the API Key page, and select the Copy icon to the right of the key to copy it to your clipboard.
Install the SDK
Install the twelvelabs-js
package:
Initialize the SDK
- Import the required packages:
- Instantiate the SDK client with your API key.:
Search
Follow the steps in this section to search through your video content and find specific moments, scenes, or information.
Steps:
- Create an index, enabling the Marengo video understanding engine.
- Upload videos and monitor the processing.
- Perform a search request, using text or images as queries.
Notes
- The search scope is an individual index.
- Results support pagination, filtering, sorting, and grouping.
Classify
Deprecation notice
The Classify API has been deprecated on Feb 28, 2025.
Recommended alternative: Update to the 1.3 version of the API and use the Pegasus video understanding model to classify videos.
Resources: Migration guide > Use Pegasus to classify videos.
Create text, image, and audio embeddings
This workflow guides you through creating embeddings for text.
Steps:
Note
Creating text embeddings is a synchronous process.
Create video embeddings
This workflow guides you through creating embeddings for videos..
Steps:
- Upload a video and monitor the processing.
- Retrieve the embeddings.
Generate text from videos
Follow the steps in this section to generate texts based on your videos.
Steps:
- Create an index, enabling the Pegasus video understanding engine.
- Upload videos and monitor the processing.
- Depending on your use case, generate one of the following:
Note
When generating open-ended texts, the platform supports streaming responses.
Extract video data
Follow the steps in this guide to extract various types of data from your videos, such as transcriptions, on-screen text, logos, and thumbnails.
Steps:
- Create an index, enabling the Marengo video understanding engine.
- Upload videos and monitor the processing.
- Depending on your use case: