Mistral API key setup
Published 2026-10-13 · Updated 2026-10-18
Mistral keys have no prefix at all, just 32 letters and digits. That makes them the easiest key to lose in a config file and the hardest to spot in a log.
Setup
export MISTRAL_API_KEY="..."
Base URL: https://api.mistral.ai/v1. Fully OpenAI-compatible for chat.
Verify
curl https://api.mistral.ai/v1/models \
-H "Authorization: Bearer $MISTRAL_API_KEY"
from openai import OpenAI
import os
client = OpenAI(
api_key=os.environ["MISTRAL_API_KEY"],
base_url="https://api.mistral.ai/v1",
)
resp = client.chat.completions.create(
model="mistral-large-3",
messages=[{"role": "user", "content": "Say hello"}],
)
print(resp.choices[0].message.content)
There’s also an official mistralai SDK if you want typed helpers, but the OpenAI path covers chat, embeddings and function calling.
Notes
- No-prefix keys are ambiguous. A bare 32-char alnum string could be Mistral, an old Cohere trial key, or half a dozen other services. If a “Mistral” key 401s, check where it actually came from.
- Codestral has its own endpoint (
codestral.mistral.ai) and historically its own keys. A La Plateforme key won’t always work there and vice versa. - Free tier exists.
console.mistral.aioffers an experiment tier with decent rate limits, good for evals, tight for production. - Service tiers. Like OpenAI, Mistral supports
service_tierfor priority/flex processing on supported models.
If you’re picking a Mistral model id, /v1/models on your key is authoritative, the catalog rotates faster than most docs.