Chat Completions
Generate conversational responses using Mistral models through the same unified chat completions endpoint you use for every other provider.
/v1/chat/completionsSupported Models
| Model | Provider | Description |
|---|---|---|
mistral-large-latest | Mistral | Highest capability, always points at the current large release |
mistral-small-latest | Mistral | Lower cost and latency for routine work |
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
modelstringrequiredModel ID — e.g. "mistral-large-latest"
messagesarrayrequiredArray of message objects with role and content
temperaturenumberSampling temperature
max_tokensintegerMaximum tokens to generate
top_pnumberNucleus sampling parameter
streambooleanEnable server-sent events streaming
Default: false
toolsarrayOpenAI-format function tools, forwarded unchanged
tool_choicestring | objectControl tool selection behavior
Options: auto, none, required
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
}'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);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"])Response
Response Fields
idstringUnique completion ID
objectstringAlways "chat.completion"
createdintegerUnix timestamp
modelstringModel used for completion
choicesarrayArray of completion choices
usageobjectToken usage statistics
{
"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.
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 || '');
}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="")