Mistral AI
Mistral API integration - Access Mistral Large, Mistral Medium, Codestral through UniterRouter. OpenAI-compatible format with function calling and JSON mode support.
Mistral AI API
Access Mistral AI models through UniterRouter using the OpenAI-compatible API format. Mistral offers efficient European-developed models with strong multilingual capabilities.
Quick Start
curl https://api.uniterouter.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $UNITEROUTER_API_KEY" \
-d '{
"model": "mistral-large-latest",
"messages": [
{"role": "user", "content": "Explain the theory of relativity"}
]
}'from openai import OpenAI
client = OpenAI(
base_url="https://api.uniterouter.ai/v1",
api_key="your_uniterouter_api_key",
)
response = client.chat.completions.create(
model="mistral-large-latest",
messages=[
{"role": "user", "content": "Explain the theory of relativity"}
]
)
print(response.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.uniterouter.ai/v1",
apiKey: process.env.UNITEROUTER_API_KEY,
});
const response = await client.chat.completions.create({
model: "mistral-large-latest",
messages: [
{ role: "user", content: "Explain the theory of relativity" }
],
});
console.log(response.choices[0].message.content);Available Models
| Model | Description | Context | Best For |
|---|---|---|---|
mistral-large-latest | Most capable model | 128K | Complex tasks, reasoning |
mistral-medium-latest | Balanced performance | 32K | General purpose |
mistral-small-latest | Fast and efficient | 32K | Quick tasks, cost-effective |
open-mistral-nemo | Open-weight model | 128K | Open-source use cases |
codestral-latest | Code-specialized | 32K | Coding, debugging |
pixtral-large-latest | Vision model | 128K | Image understanding |
Function Calling
Mistral models support function calling:
tools = [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather for a location",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string", "description": "City name"},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
},
"required": ["location"]
}
}
}
]
response = client.chat.completions.create(
model="mistral-large-latest",
messages=[{"role": "user", "content": "What's the weather in Paris?"}],
tools=tools,
tool_choice="auto"
)JSON Mode
Request structured JSON output:
response = client.chat.completions.create(
model="mistral-large-latest",
messages=[
{"role": "user", "content": "List 3 programming languages with their use cases"}
],
response_format={"type": "json_object"}
)Vision (Pixtral)
Use Pixtral for image understanding:
response = client.chat.completions.create(
model="pixtral-large-latest",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "What's in this image?"},
{
"type": "image_url",
"image_url": {"url": "https://example.com/image.jpg"}
}
]
}
]
)Coding with Codestral
Specialized for code generation:
response = client.chat.completions.create(
model="codestral-latest",
messages=[
{"role": "system", "content": "You are an expert programmer."},
{"role": "user", "content": "Write a quicksort algorithm in Python"}
]
)Streaming
stream = client.chat.completions.create(
model="mistral-large-latest",
messages=[{"role": "user", "content": "Tell me about AI"}],
stream=True
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")Features
- Multilingual: Excellent support for European languages
- Efficient: Optimized inference speed
- Function Calling: Full tool use support
- Vision: Image understanding with Pixtral
- Code: Specialized coding models
Related
- Chat Completions - Full API documentation
- Vision - Image input guide
How is this guide?
DeepSeek
DeepSeek API integration - Access DeepSeek V3, DeepSeek Coder models through UniterRouter. OpenAI-compatible format for seamless migration from ChatGPT.
xAI (Grok)
xAI Grok API integration - Access Grok-2, Grok-1.5 through UniterRouter. OpenAI-compatible format for Elon Musk's AI with real-time knowledge and reasoning.