Mixpeek Quickstart Guide

There is an interactive version of this guide embedded in your dashboard on the Notebooks page

Getting Started

First, install the required libraries:

pip install requests

import requests
import json

# Replace with your Mixpeek API key
API_KEY = "YOUR_API_KEY"
BASE_URL = "https://api.mixpeek.com"

headers = {
    'Authorization': f'Bearer {API_KEY}',
    'Content-Type': 'application/json'
}

Indexing Content

You can index various types of content including images, videos, and text:

Image Indexing

url = f"{BASE_URL}/index/images/url"

image_payload = {
    "url": "https://example.com/sample-image.jpg",
    "collection_id": "quickstart",
    "metadata": {
        "title": "Sample Image",
        "category": "demo"
    },
    "feature_extractors": {
        "embed": [
            {
                "type": "url",
                "vector_name": "image"
            }
        ],
        "describe": {
            "enabled": True,
            "vector_name": "text"
        }
    }
}

response = requests.post(url, headers=headers, json=image_payload)
print(json.dumps(response.json(), indent=2))

Video Indexing

url = f"{BASE_URL}/index/videos/url"

video_payload = {
    "url": "https://example.com/sample-video.mp4",
    "collection_id": "quickstart",
    "metadata": {
        "title": "Sample Video",
        "category": "demo"
    },
    "feature_extractors": [{
        "interval_sec": 15,
        "embed": [
            {
                "type": "url",
                "vector_name": "multimodal"
            }
        ],
        "transcribe": {"enabled": True},
        "describe": {"enabled": True}
    }]
}

response = requests.post(url, headers=headers, json=video_payload)
print(json.dumps(response.json(), indent=2))

Text Indexing

url = f"{BASE_URL}/index/text"

text_payload = {
    "collection_id": "quickstart",
    "metadata": {
        "title": "Sample Text",
        "category": "demo"
    },
    "feature_extractors": {
        "embed": [
            {
                "field_name": "content",
                "type": "text",
                "value": "Your text content here",
                "vector_name": "text"
            }
        ]
    }
}

response = requests.post(url, headers=headers, json=text_payload)
print(json.dumps(response.json(), indent=2))

Searching Content

Now you can perform both text and vector searches across your collections:

url = f"{BASE_URL}/features/search"

payload = {
    "queries": [
        # Text vector search
        {
            "vector_index": "text",
            "value": "dog jumping in the park",
            "type": "text",
            "settings": {
                "limit": 10,
                "relevance_threshold": 0.5
            }
        },
        # Image vector search (using URL)
        {
            "vector_index": "image",
            "value": "https://example.com/sample-image.jpg",
            "type": "url",
            "settings": {
                "limit": 10,
                "relevance_threshold": 0.7
            }
        }
    ],
    "collection_ids": ["quickstart"],
    "filters": {
        "AND": [
            {
                "key": "metadata.category",
                "value": "animals",
                "operator": "eq"
            }
        ]
    }
}

response = requests.post(url, headers=headers, json=payload)
search_results = response.json()
print(json.dumps(search_results, indent=2))

Next Steps