For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Sample appsIntegrationsDiscordPlaygroundDevEx repo
GuidesSDK ReferenceAPI Reference
GuidesSDK ReferenceAPI Reference
  • Get Started
    • Introduction
    • Quickstart
    • Manage your plan
    • Rate limits
    • Release notes
    • Migration guide
  • Guides
    • Search
    • Analyze videos
    • Segment videos
    • Create embeddings
      • Video embeddings
      • Audio embeddings
      • Text embeddings
      • Single image embeddings
      • Text and image embeddings
  • Concepts
    • Models
    • Upload and processing methods
    • Indexes
    • Modalities
    • Multimodal large language models
  • Cloud partner integrations
    • Amazon Bedrock
  • Advanced
    • Organizations
    • Fine-tuning
    • Webhooks
    • Metadata
    • Model context protocol
    • Claude Code Plugin
  • Resources
    • Platform overview
    • Playground
    • TwelveLabs SDKs
    • Frequently asked questions
    • Use cases
    • Sample applications
    • Partner integrations
    • From the community
LogoLogo
Sample appsIntegrationsDiscordPlaygroundDevEx repo
On this page
  • Key concepts
  • Workflow
  • Prerequisites
  • Complete example
  • Code explanation
GuidesCreate embeddings

Text embeddings

Was this page helpful?
Previous

Single image embeddings

Next
Built with

This guide shows how you can create text embeddings using the Marengo video understanding model. For a list of available versions, complete specifications and input requirements for each version, see the Marengo page.

The Marengo video understanding model generates embeddings for all modalities in the same latent space. This shared space enables any-to-any searches across different types of content.

For details on how your usage is measured and billed, see the Pricing page.

Key concepts

This section explains the key concepts and terminology used in this guide:

  • Embedding: Vector representation of your content.

Workflow

This guide shows how to create text embeddings by passing text directly to the platform. The platform returns your embeddings immediately in the response.

Use these embeddings for similarity search, content classification, clustering, recommendations, or Retrieval-Augmented Generation (RAG).

Prerequisites

  • To use the platform, you need an API key:

    1

    If you don’t have an account, sign up for a free account.

    2

    Go to the API Keys page.

    3

    If you need to create a new key, select the Create API Key button. Enter a name and set the expiration period. The default is 12 months.

    4

    Select the Copy icon next to your key to copy it to your clipboard.

  • Depending on the programming language you are using, install the TwelveLabs SDK by entering one of the following commands:

    $pip install twelvelabs

Complete example

Copy and paste the code below, replacing the placeholders surrounded by <> with your values.

1from twelvelabs import TwelveLabs, TextInputRequest
2
3# 1. Initialize the client
4client = TwelveLabs(api_key="<YOUR_API_KEY>")
5
6# 2. Create text embeddings
7response = client.embed.v_2.create(
8 input_type="text",
9 model_name="marengo3.0",
10 text=TextInputRequest(
11 input_text="<YOUR_TEXT>"
12 )
13)
14
15# 3. Process the results
16print(f"Number of embeddings: {len(response.data)}")
17for embedding_data in response.data:
18 print(f"Embedding dimensions: {len(embedding_data.embedding)}")
19 print(f"First 10 values: {embedding_data.embedding[:10]}")

Code explanation

Python
Node.js
1

Import the SDK and initialize the client

Create a client instance to interact with the TwelveLabs Video Understanding Platform.
Function call: You call the constructor of the TwelveLabs class.
Parameters:

  • api_key: The API key to authenticate your requests to the platform.

Return value: An object of type TwelveLabs configured for making API calls.

2

Create text embeddings

Function call: You call the embed.v_2.create function.
Parameters:

  • input_type: The type of content. Set this parameter to text.
  • model_name: The model you want to use. This example uses marengo3.0.
  • text: A TextInputRequest object containing the following properties:
    • input_text: The text for which you wish to create an embedding.

Return value: An object of type EmbeddingSuccessResponse containing a field named data, which is a list of embedding objects. Each embedding object includes the following fields:

  • embedding: An array of floats representing the embedding vector.
  • embedding_option: The type of embedding generated.
3

Process the results

This example prints the number of embeddings, their dimensions, and the first 10 values of each embedding.