Skip to main content
Wire Mixpeek retrievers into OpenAI’s function calling API so GPT models can search video, image, and audio content on demand.
There is no langchain-mixpeek package. You use the standard mixpeek SDK and wrap it as an OpenAI function. This gives you full control over input parsing, error handling, and response formatting.

The Pattern

OpenAI function calling lets GPT models decide when to invoke external tools during a conversation. You define a function schema, register it as a tool, and handle the call in your completion loop.
1

Define the function schema

Describe search_mixpeek with a name, description, and parameters so the model knows when and how to call it.
2

Register it as a tool

Pass the schema in the tools array when calling chat.completions.create().
3

Handle tool calls in the completion loop

When the model returns tool_calls, execute client.retrievers.execute() with the provided arguments and append the results as a tool message.
4

Get the final response

Call chat.completions.create() again with the tool results. The model incorporates the search results into its answer.

Installation

Function Schema

Define a function that tells GPT what Mixpeek search does and what inputs it accepts:
Write a specific description that tells the model when to call this tool. Mention the content types your retriever handles (video, images, audio). Generic descriptions like “search for things” cause the model to over- or under-use the function.

Full Working Example: Chat Completions API

Assistants API

You can register Mixpeek search as a tool on an OpenAI Assistant. The Assistants API manages conversation state and persistent threads for you.

Tips

Write Descriptive Function Schemas

The description field on your function and its parameters directly affects when and how the model calls your tool. Be specific about what content types your retriever handles.

Limit Result Size for Token Efficiency

Every result you return gets added to the conversation context. Strip unnecessary fields and cap the number of results to avoid wasting tokens.

Handle Errors Gracefully

Return error messages as tool output instead of raising exceptions. This lets the model recover or ask the user to rephrase.
If you use parallel_tool_calls (enabled by default in the Chat Completions API), the model may issue multiple search_mixpeek calls in a single response. The handler loop in the examples above already supports this — each tool call is processed independently.

Next Steps

LangChain

Use Mixpeek as a LangChain tool for agent workflows

MCP Server

Connect Claude directly via the Model Context Protocol

Retriever Stages

Configure multi-stage search pipelines

Python SDK

Full SDK reference