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

If you’re picking a Mistral model id, /v1/models on your key is authoritative, the catalog rotates faster than most docs.