Skip to main content
This guide shows how to integrate Seltz as a search tool for Mistral models. When Mistral needs to search for information, it will call your Seltz-powered function and use the results to generate informed responses.

Prerequisites

Installation

Setup

Set your API keys as environment variables:
Initialize both clients:

Define the Search Tool

Create a tool schema that describes the Seltz search function to Mistral:

Using the Chat API

Here’s a complete example using Mistral’s Chat API with Seltz search:

How It Works

  1. User sends a message - The user asks a question that may require search
  2. Mistral decides to search - The model determines if it needs external information
  3. Tool call is made - Mistral returns a tool call with the search query
  4. Seltz executes search - Your code calls Seltz with the query
  5. Results sent back - Search results are added to the conversation
  6. Final response - Mistral generates a response using the search results

Streaming Responses

Stream the final response for better user experience:

Multi-Turn Conversations

Maintain conversation history for follow-up questions:

Available Models

Mistral models that support function calling:

Error Handling

Handle Seltz errors gracefully so Mistral can respond appropriately:

Best Practices

Mistral uses the description to decide when to use the tool. Be explicit about what information the search provides and when it should be used.
Use mistral-large-latest for complex queries requiring nuanced understanding. Use smaller models for straightforward searches to reduce latency and cost.
Return error information as JSON so Mistral can inform the user or suggest alternatives.
Stream the final response so users see output immediately rather than waiting for the complete response.

Next Steps

OpenAI Tool Calling

Integrate with OpenAI models.

Anthropic Tool Calling

Integrate with Claude models.