Mistral AI API
api.mistral.ai · AI
Mistral AI models via API — Mistral 7B, Mixtral 8x7B, Mistral Large, and open-source weights. OpenAI-compatible endpoint. Free tier: 1B tokens/month.
Authentication
Bearer Token
Free API key at console.mistral.ai. Pass as Authorization: Bearer YOUR_KEY.
Sample Requests
POST
Chat completion
Chat with Mistral Small.
https://api.mistral.ai/v1/chat/completions
Hover any highlighted part to learn what it does
Headers — extra info sent with the request
| Content-Type | application/json |
| Authorization | Bearer YOUR_KEY |
Request Body — data you're sending
{
"model": "mistral-small-latest",
"messages": [
{
"role": "user",
"content": "What is the meaning of life?"
}
]
}
curl -X POST "https://api.mistral.ai/v1/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"model":"mistral-small-latest","messages":[{"role":"user","content":"What is the meaning of life?"}]}'import requests
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_ACCESS_TOKEN"
}
data = {
"model": "mistral-small-latest",
"messages": [
{
"role": "user",
"content": "What is the meaning of life?"
}
]
}
response = requests.post(
"https://api.mistral.ai/v1/chat/completions",
headers=headers,
json=data,
)
print(response.json())const url = 'https://api.mistral.ai/v1/chat/completions';
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
},
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
"model": "mistral-small-latest",
"messages": [
{
"role": "user",
"content": "What is the meaning of life?"
}
]
}),
});
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"bytes"
"encoding/json"
)
func main() {
targetURL := "https://api.mistral.ai/v1/chat/completions"
jsonData, _ := json.Marshal({"model":"mistral-small-latest","messages":[{"role":"user","content":"What is the meaning of life?"}]})
req, _ := http.NewRequest("POST", targetURL, bytes.NewBuffer(jsonData))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer YOUR_ACCESS_TOKEN")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://api.mistral.ai/v1/chat/completions")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Post.new(uri)
req["Content-Type"] = "application/json"
req["Authorization"] = "Bearer YOUR_ACCESS_TOKEN"
req["Content-Type"] = "application/json"
req.body = "{\"model\":\"mistral-small-latest\",\"messages\":[{\"role\":\"user\",\"content\":\"What is the meaning of life?\"}]}"
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://api.mistral.ai/v1/chat/completions";
$opts = ["http" => [
"method" => "POST",
"header" => implode("\r\n", [
"Content-Type: application/json",
"Authorization: Bearer YOUR_ACCESS_TOKEN",
"Content-Type: application/json"
]),
"content" => json_encode({"model":"mistral-small-latest","messages":[{"role":"user","content":"What is the meaning of life?"}]}),
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));
GET
List models
List available Mistral models.
https://api.mistral.ai/v1/models
Hover any highlighted part to learn what it does
Headers — extra info sent with the request
| Authorization | Bearer YOUR_KEY |
curl -X GET "https://api.mistral.ai/v1/models" \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
import requests
headers = {
"Authorization": "Bearer YOUR_ACCESS_TOKEN"
}
response = requests.get(
"https://api.mistral.ai/v1/models",
headers=headers,
)
print(response.json())const url = 'https://api.mistral.ai/v1/models';
const response = await fetch(url, {
headers: {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
},
});
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
)
func main() {
targetURL := "https://api.mistral.ai/v1/models"
req, _ := http.NewRequest("GET", targetURL, nil)
req.Header.Set("Authorization", "Bearer YOUR_ACCESS_TOKEN")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://api.mistral.ai/v1/models")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
req["Authorization"] = "Bearer YOUR_ACCESS_TOKEN"
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://api.mistral.ai/v1/models";
$opts = ["http" => [
"method" => "GET",
"header" => implode("\r\n", [
"Authorization: Bearer YOUR_ACCESS_TOKEN"
]),
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Postman Setup Guide
- Get a free API key at console.mistral.ai
- Set Authorization: Bearer YOUR_KEY
- Endpoint is OpenAI-compatible — works with any OpenAI SDK
- Models: mistral-small-latest, mistral-medium-latest, mistral-large-latest, mistral-embed
- Free tier: 1 billion tokens/month (note: prompts may be used for training)