---
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.  Processing a Large Media Library

Back to code examples

TrainingEnhanced

# Processing a Large Media Library

Run extraction over tens of thousands of files without paying for the same object twice. Price the job before you submit it, keep new uploads flowing in on their own, and move cold collections out of the vector store while they stay searchable.

video

image

audio

text

Production

[Run in Builder](/build?recipe=scalable-multimodal-processing)

### Why This Matters

Extraction is the expensive part, and the bill is set by how many objects reach a GPU. A library that grows every day will re-pay for everything it already holds unless the pipeline knows what it has seen.

Python

cURL

import os, json, urllib.request

from mixpeek import Mixpeek

client \= Mixpeek(api\_key\=os.environ\["MIXPEEK\_API\_KEY"\], namespace\="media-library")

BUCKET\_ID \= "bkt\_your\_library"

BATCH\_ID \= "bat\_the\_draft\_you\_just\_created"

COLLECTION\_ID \= "col\_enriched\_media"

ARCHIVE\_COLLECTION\_ID \= "col\_2019\_archive"

CONNECTION\_ID \= "con\_your\_s3\_connection"

BASE \= "https://api.mixpeek.com/v1"

HEADERS \= {

    "Authorization": f"Bearer {os.environ\['MIXPEEK\_API\_KEY'\]}",

    "X-Namespace": "media-library",

    "Content-Type": "application/json",

}

def api(method, path, body\=None):

    """The facade covers buckets, collections, retrievers, documents,

    evaluations, tasks and namespaces. Batch cost, bucket syncs and collection

    lifecycle have no resource on it yet, so those three go over HTTP."""

    req \= urllib.request.Request(

        f"{BASE}{path}",

        method\=method,

        data\=json.dumps(body).encode() if body is not None else None,

        headers\=HEADERS,

    )

    with urllib.request.urlopen(req) as r:

        return json.load(r)

\# 1. Price the run before you spend anything. estimate-cost consumes no credits

\#    and changes nothing about the batch. already\_extracted\_count is the number

\#    you care about: under 'force' or 'replace' those objects go back through a

\#    GPU and estimated\_repay\_credits is what that costs.

est \= api("POST", f"/buckets/{BUCKET\_ID}/batches/{BATCH\_ID}/estimate-cost")

print(est\["object\_count"\], "objects,", est\["already\_extracted\_count"\], "already done")

print(est\["estimated\_credits"\], "credits")

if est.get("estimated\_usd") is not None:

    print("approx USD:", round(est\["estimated\_usd"\], 2))

for w in est.get("warnings", \[\]):

    print("warning:", w)

\# 2. Run it. dedup\_strategy defaults to 'skip' and is scoped to

\#    (bucket, collection), so re-triggering after the bucket grows pays only for

\#    the new objects. Reach for 'replace' when the extractor itself changed and

\#    the old documents are wrong; 'force' allows duplicates and is rarely what

\#    you want.

client.collections.trigger(COLLECTION\_ID, dedup\_strategy\="skip")

\# 3. Stop triggering by hand. A sync watches the bucket's storage connection and

\#    submits what lands. skip\_duplicates is on by default and does the same job

\#    as dedup\_strategy for objects arriving continuously.

sync \= api("POST", f"/buckets/{BUCKET\_ID}/syncs", {

    "connection\_id": CONNECTION\_ID,

    "source\_path": "incoming/",

    "sync\_mode": "continuous",

    "polling\_interval\_seconds": 300,

    "batch\_size": 50,

    "skip\_duplicates": True,

})

\# 4. Keep the hot set small. 'cold' evicts a collection's vectors from the vector

\#    store and they stay searchable from object storage; 'active' rehydrates.

\#    Search latency is set by what is resident, so an archive that nobody queries

\#    should not be.

api("PATCH", f"/collections/{ARCHIVE\_COLLECTION\_ID}/lifecycle",

    {"lifecycle\_state": "cold"})

### 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

### Documentation

[Batches](https://mixpeek.com/docs/api-reference/batches/list-all-batches)[Bucket Syncs](https://mixpeek.com/docs/api-reference/bucket-syncs/list-sync-configurations)[Collections](https://mixpeek.com/docs/api-reference/collections/create-collection)

## Frequently asked questions

### How do I process thousands of videos without re-paying for the ones already done?

Leave dedup\_strategy on its default of 'skip'. It is scoped to (bucket, collection), so an object counts as done if the target collection already holds documents produced from it, whichever batch made them. Re-trigger after the bucket grows and only the new objects reach a GPU. Before submitting anything, POST to the batch's estimate-cost endpoint: it returns object\_count, already\_extracted\_count and estimated\_credits without consuming credits or changing the batch.

### What actually drives the cost of processing a large library?

How many objects reach an extractor, and which features you ask for. The cost estimate breaks this out as content\_summary (file types and how much of each, including video minutes) and features (what the batch will let you search by). If you are using replace or force, estimated\_repay\_credits is the part of the bill that buys you nothing new.

### How do I process new uploads automatically as they arrive?

Create a sync on the bucket. With sync\_mode "continuous" it polls the storage connection every polling\_interval\_seconds (300 by default) and submits what it finds in batches of batch\_size (50 by default). skip\_duplicates defaults to true. max\_objects\_per\_run caps a single run if you want a hard ceiling while you are still tuning it.

### How do I keep search fast once the library is large?

Shrink what is resident. PATCH a collection's lifecycle to "cold" and its vectors leave the vector store while staying searchable through object storage; "active" brings them back. Latency tracks the size of the hot set, so a five-year archive that nobody queries should not be sitting in it.

### Can I do all of this from the Python SDK?

Partly. client.collections.trigger(collection\_id, dedup\_strategy=...) is on the client. Batch cost estimation, bucket syncs and collection lifecycle have no resource manager on it yet, so those three are plain HTTP calls against the same API key.

## 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

### 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)[

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

### Dataset Versioning

Treat versioned object storage as your dataset's source of truth. Capture complete snapshots-raw assets, embeddings, and cluster assignments-for deterministic reconstruction at any point in time.

Learn more





](/recipes/dataset-versioning)[

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

### Clustering & Theme Discovery

Unsupervised clustering that groups content into semantic themes using HDBSCAN. Surfaces hidden patterns, content variants, and outliers without requiring predefined labels.

Learn more





](/recipes/clustering-theme-discovery)