Chat · Mistral

Chat Completions

Generate conversational responses using Mistral models through the same unified chat completions endpoint you use for every other provider.

POST/v1/chat/completions
Already OpenAI-shaped
Mistral speaks the OpenAI chat format natively, so the gateway forwards your request with the field names unchanged and streams its chunks straight through without normalizing them.

Supported Models

ModelProvider
mistral-large-latestMistral
mistral-small-latestMistral

These two aliases always resolve to a current release. Call GET /v1/models for the full list your key can reach, including pinned versions and the code and vision families.

Request

Body Parameters

modelstringrequired

Model ID — e.g. "mistral-large-latest"

messagesarrayrequired

Array of message objects with role and content

temperaturenumber

Sampling temperature

max_tokensinteger

Maximum tokens to generate

top_pnumber

Nucleus sampling parameter

streamboolean

Enable server-sent events streaming

Default: false

toolsarray

OpenAI-format function tools, forwarded unchanged

tool_choicestring | object

Control tool selection behavior

Options: auto, none, required

cURL
curl https://api.metriqual.com/v1/chat/completions \
  -H "Authorization: Bearer mql_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "mistral-large-latest",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "What is quantum computing?"}
    ],
    "temperature": 0.7,
    "max_tokens": 500
  }'
TypeScript SDK
const response = await mql.chat.create({
  model: 'mistral-large-latest',
  messages: [
    { role: 'system', content: 'You are a helpful assistant.' },
    { role: 'user', content: 'What is quantum computing?' }
  ],
  temperature: 0.7,
  max_tokens: 500
});

console.log(response.choices[0].message.content);
Python SDK
response = mql.chat.create(
    model="mistral-large-latest",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "What is quantum computing?"},
    ],
    temperature=0.7,
    max_tokens=500,
)
print(response["choices"][0]["message"]["content"])
Text messages only
The Mistral adapter sends each message's content as a single string. Content arrays with image_url objects are not converted, so send images to an OpenAI or MiniMax model instead. Only the parameters in the table above are forwarded.

Response

Response Fields

idstring

Unique completion ID

objectstring

Always "chat.completion"

createdinteger

Unix timestamp

modelstring

Model used for completion

choicesarray

Array of completion choices

usageobject

Token usage statistics

200
{
  "id": "chatcmpl-mistral-abc123",
  "object": "chat.completion",
  "created": 1705320000,
  "model": "mistral-large-latest",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Quantum computing is a type of computation..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 25,
    "completion_tokens": 150,
    "total_tokens": 175
  }
}

Streaming

Set stream: true to receive incremental responses via Server-Sent Events. Mistral chunks are already OpenAI-shaped, so they pass through untouched.

TypeScript SDK Streaming
for await (const chunk of mql.chat.stream({
  model: 'mistral-large-latest',
  messages: [{ role: 'user', content: 'Tell me a story' }]
})) {
  process.stdout.write(chunk.choices[0]?.delta?.content || '');
}
Python SDK Streaming
for chunk in mql.chat.stream(
    model="mistral-large-latest",
    messages=[{"role": "user", "content": "Tell me a story"}],
):
    print(chunk["choices"][0]["delta"].get("content", ""), end="")