UniterRouter
API ReferenceMistral AI

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

ModelDescriptionContextBest For
mistral-large-latestMost capable model128KComplex tasks, reasoning
mistral-medium-latestBalanced performance32KGeneral purpose
mistral-small-latestFast and efficient32KQuick tasks, cost-effective
open-mistral-nemoOpen-weight model128KOpen-source use cases
codestral-latestCode-specialized32KCoding, debugging
pixtral-large-latestVision model128KImage 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

How is this guide?