> This page is for version v1.3 (default).
> For other versions, use one of these documentation indexes:
> - v1.3 (default): https://docs.twelvelabs.io/v1.3/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.twelvelabs.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.twelvelabs.io/_mcp/server.

# LanceDB - Building advanced video understanding applications

> Create advanced video understanding apps using the TwelveLabs Embed API with LanceDB.

![](/_fern-img/5b7c8300e4c5bbca28b639f40855bc308a082cc9e19abb37c3f3b1c76f2b2feb.webp)

**Summary**: This integration allows you to create advanced video understanding and retrieval applications. It combines two key components:

* [**TwelveLabs' Embed API**](/docs/guides/create-embeddings): Generates multimodal embeddings for video content and text.
* [**LanceDB**](https://lancedb.com): A serverless vector database that stores, indexes, and queries high-dimensional vectors at scale.

Key use cases include:

* Semantic video search engines
* Content-based recommendation systems
* Anomaly detection in video streams.

**Description**: The process of performing a semantic video search using Twleve Labs and LanceDB involves two main steps:

1. Use the Embed API to create multimodal embeddings for video content and text queries.
2. Use the embeddings to perform similarity searches in LanceDB.

**Code explanation**: Our blog post, [Building Advanced Video Understanding ApplicationsL Integrating TwelveLabs Embed API with LanceDB for Multimodal AI](https://www.twelvelabs.io/blog/twelve-labs-and-lancedb), guides you through the process of creating a video search application, from setup to generating video embeddings and querying them efficiently.\
**Colab Notebook**: [TwelveLabs-EmbedAPI-LanceDB](https://colab.research.google.com/drive/1ujc-_QkOgJjszOHq5EXqU767QWJGCAZm?usp=sharing)

# Integration with TwelveLabs

This section describes how you can use the [TwelveLabs Python SDK](https://github.com/twelvelabs-io/twelvelabs-python) to create embeddings for videos and text queries.

## Video embeddings

The `generate_embedding` function takes the URL of a video as a parameter and returns a list of dictionaries, each containing an embedding vector and the associated metadata:

**`Node.js`**

```javascript Node.js
from twelvelabs.models.embed import EmbeddingsTask

def generate_embedding(video_url: str) -> tuple[List[Dict[str, Any]], Any]:
    """Generate embeddings for a given video URL."""
    task = twelvelabs_client.embed.task.create(
        engine_name="Marengo-retrieval-2.7",
        video_url=video_url
    )
    
    def on_task_update(task: EmbeddingsTask):
        print(f"  Status={task.status}")

    task.wait_for_done(sleep_interval=2, callback=on_task_update)
    task_result = twelvelabs_client.embed.task.retrieve(task.id)

    embeddings = [{
        'embedding': v.embedding.float,
        'start_offset_sec': v.start_offset_sec,
        'end_offset_sec': v.end_offset_sec,
        'embedding_scope': v.embedding_scope
    } for v in task_result.video_embeddings]
    
    return embeddings, task_result
```

For more details, see the [Video embeddings](/docs/guides/create-embeddings/at-scale/video) page.

## Text embeddings

The `get_text_embedding` function generates embeddings for text queries:

**`Node.js`**

```javascript Node.js
def get_text_embedding(text_query: str) -> List[float]:
    """Generate a text embedding for a given text query."""
    return twelvelabs_client.embed.text(text_query).embedding.float

```

For more details, see the [Embed a query](/docs/guides/create-embeddings/query) page.

# Next steps

After reading this page, you have the following options:

* **Customize and use the example**: Use the [TwelveLabs-EmbedAPI-LanceDB](https://colab.research.google.com/drive/1ujc-_QkOgJjszOHq5EXqU767QWJGCAZm?usp=sharing) notebook to understand how the integration works. You can make changes and add more functionalities to suit your specific use case. Some notable examples include:
  * Explore advanced features in LanceDB like [hybrid search combining vector and metadata filtering](https://lancedb.github.io/lancedb/hybrid_search/hybrid_search/).
  * Implement a continuous user feedback loop to improve your search and recommendation results.
* **Explore further**: Try the [applications built by the community](https://docs.twelvelabs.io/docs/from-the-community) or our [sample applications](https://docs.twelvelabs.io/docs/sample-applications) to get more insights into the TwelveLabs Video Understanding Platform's diverse capabilities and learn more about integrating the platform into your applications.