---
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://mixpeek.com/.well-known/search?q={query}"
  method: GET
  documentation: "https://mixpeek.com/llms.txt"
---

1.  [](/)
2.  [Code examples](/recipes)
3.  Video RAG Pipeline

Back to code examples

# Video RAG Pipeline

Retrieval-augmented generation specifically designed for video content. Decomposes videos into scenes and transcripts, retrieves relevant segments for a given question, and passes them as context to an LLM with precise timestamp citations.

video

text

audio

Multi-Stage

[Run in Builder](/build?recipe=video-rag-pipeline)

Python

cURL

from mixpeek import Mixpeek

client \= Mixpeek(api\_key\="YOUR\_API\_KEY", namespace\="training-videos")

\# 1. Training videos are cut at pauses, transcribed, and each passage is embedded

bucket \= client.buckets.create(

    bucket\_name\="training-videos",

    bucket\_schema\={"properties": {"video": {"type": "video"}}},

)

collection \= client.collections.create(

    collection\_name\="training-videos",

    source\={"type": "bucket", "bucket\_ids": \[bucket\["bucket\_id"\]\]},

    feature\_extractor\={

        "feature\_extractor\_name": "multimodal\_extractor",

        "version": "v1",

        "parameters": {

            "split\_method": "silence",

            "run\_transcription": True,

            "run\_transcription\_embedding": True,

        },

    },

)

client.buckets.upload(

    bucket\["bucket\_id"\],

    blobs\=\[{"property": "video", "type": "video", "data": "s3://your-bucket/training/firewall-setup.mp4"}\],

)

client.collections.trigger(collection\["collection\_id"\])

\# 2. The retriever finds passages, reranks them and writes the answer

retriever \= client.retrievers.create(

    retriever\_name\="video-rag",

    collection\_identifiers\=\["training-videos"\],

    input\_schema\={"query": {"type": "text", "required": True}},

    stages\=\[

        {

            "stage\_name": "search",

            "stage\_id": "feature\_search",

            "parameters": {

                "searches": \[

                    {

                        "feature\_uri": "mixpeek://multimodal\_extractor@v1/multilingual\_e5\_large\_instruct\_v1",

                        "query": {"input\_mode": "text", "value": "{{INPUT.query}}"},

                        "top\_k": 50,

                    },

                \],

                "final\_top\_k": 50,

            },

        },

        {

            "stage\_name": "rerank",

            "stage\_id": "rerank",

            "parameters": {

                "inference\_name": "BAAI\_\_bge\_reranker\_v2\_m3",

                "query": "{{INPUT.query}}",

                "document\_field": "transcription",

                "top\_k": 8,

            },

        },

        {

            "stage\_name": "answer",

            "stage\_id": "summarize",

            "parameters": {

                "prompt": "Answer the question {{INPUT.query}} using only these numbered passages, and cite the passage numbers. {{DOCUMENTS}}",

                "provider": "google",

                "model\_name": "gemini-2.5-flash-lite",

                "content\_field": "transcription",

                "output\_field": "answer",

                "include\_sources": True,

            },

        },

    \],

)

results \= client.retrievers.execute(retriever\["retriever\_id"\], inputs\={"query": "How do I configure the firewall settings?"})

answer \= results\["documents"\]\[0\]

print(answer\["answer"\])

\# The summary document lists the documents it read; fetch them for citations

for i, document\_id in enumerate(answer.get("source\_document\_ids") or \[\], 1):

    source \= client.documents.get(collection\["collection\_id"\], document\_id)

    print(f"\[{i}\]", source.get("root\_object\_id"), source.get("start\_time"), source.get("end\_time"))

### Feature Extractors

Multimodal Extractor

Unified embeddings for video, audio, image, and text: scene/silence chunking, Whisper transcription, thumbnails, and Gemini vision.

### Retriever Stages

feature search

Search and filter documents by vector similarity using feature embeddings

filter

rerank

Rerank documents using cross-encoder models for accurate relevance

sort

summarize

Condense multiple documents into a summary using an LLM

reduce

## Frequently asked questions

### How are video segments created for RAG?

Videos are automatically decomposed into scenes using visual shot detection and audio segmentation. Each scene gets its own transcript and embedding for granular retrieval.

### Can I use any LLM for the generation step?

Yes. Mixpeek handles the retrieval and context preparation. You bring your own LLM (OpenAI, Anthropic, open-source) for the final generation step.

### How do I link the LLM answer back to specific video timestamps?

Each retrieved segment includes start\_time and end\_time fields. Include these in the LLM context so the model can cite specific timestamps in its response.

## Related code examples and resources

Pages on the same stages, extractors and patterns.

[

Extractor

### Multimodal Extractor

Unified embeddings for video, audio, image, and text: scene/silence chunking, Whisper transcription, thumbnails, and Gemini vision.

Learn more





](/extractors/multimodal)[

Recipe

### Video Transcription & Indexing Pipeline

Automatically transcribe video content with speaker identification, timestamps, and full-text indexing for downstream search and analytics.

Learn more





](/recipes/video-transcription-pipeline)[

Recipe

### Video Content Analytics Pipeline

Analyze video content at scale to extract insights: scene composition, speaker time, topic distribution, and sentiment across your video library.

Learn more





](/recipes/video-analytics-pipeline)[

Recipe

### Searchable Video Library

Turn an unstructured video archive into a fully searchable library. Each video is decomposed into scenes with transcriptions, visual embeddings, and metadata. Users search by natural language and jump directly to the relevant moment in any video.

Learn more





](/recipes/searchable-video-library)[

Recipe

### Semantic Multimodal Search

Unified semantic search across all content types. Query by natural language and retrieve relevant video clips, images, audio segments, and documents based on meaning-not keywords or manual tags.

Learn more





](/recipes/semantic-multimodal-search)[

Recipe

### Feature Extraction

Multi-tier feature extraction that decomposes content into searchable components: embeddings, transcripts, detected objects, OCR text, scene boundaries, and more. The foundation for all downstream retrieval and analysis.

Learn more





](/recipes/feature-extraction)