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.Define the function schema
Describe
search_mixpeek with a name, description, and parameters so the model knows when and how to call it.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.Installation
Function Schema
Define a function that tells GPT what Mixpeek search does and what inputs it accepts: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
Thedescription 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

