How to Get a Mistral API Key: Setup, Storage, and First Request
Getting a Mistral key takes about two minutes. Keeping it working -- and knowing whether a failure is your key, your quota, or Mistral itself -- is the part that actually costs teams time.
📡 Monitor your APIs — know when they go down before your users do
Better Stack checks uptime every 30 seconds with instant Slack, email & SMS alerts. Free tier available.
Affiliate link — we may earn a commission at no extra cost to you
A Mistral API key is a bearer credential. Anything holding it can spend your account's money, which is why the interesting part of this guide is not the four clicks that create the key -- it is where the key lives afterwards and how you diagnose it when requests start failing.
Mistral separates the free experiment tier from paid usage at the workspace level, so check which workspace is selected before you create the key.
Before you regenerate anything: 401 means the key string is wrong. 403 means the key is real but not entitled. 429 means your quota. 5xx and timeouts mean Mistral -- check live Mistral status first.
Create the Key: Five Steps
- Sign up. Create an account at console.mistral.ai and complete whatever verification the console requires.
- Open the API keys screen. In the Mistral La Plateforme console, find the API keys section.
- Create a key and name it. Name it after the thing that will use it --
prod-api,staging-worker,local-dev. Per-surface keys mean you can revoke one without an outage everywhere else. - Copy the secret immediately. It is displayed once. There is no reveal-later button.
- Store it as
MISTRAL_API_KEYin a secret manager or a git-ignored.envfile, then verify it before you build anything on top of it.
Verify the phone number before you touch the API Keys screen. Key creation fails silently-ish for unverified accounts: the button is present, the error is terse, and nothing on the page tells you verification is the blocker. Complete verification in account settings first, then create the key. Keys are also workspace-scoped, so a key minted in a personal workspace will not see a team workspace's billing or limits.
Verify It With One Request
Do this before writing any application code. A single cURL against the live endpoint separates "the key is wrong" from "my framework is not loading the environment variable" -- two failures that look identical from inside an app.
curl https://api.mistral.ai/v1/chat/completions \
-H "Authorization: Bearer $MISTRAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"mistral-large-latest","messages":[{"role":"user","content":"ping"}]}'A 200 with a completion body means the key is good. Mistral's chat endpoint is OpenAI-compatible, so an existing OpenAI client works once you change the base URL and the key.
| Response | What it actually means | Fix |
|---|---|---|
200 | Key valid, model accessible, account funded | Nothing -- wire it up |
401 | Key string wrong, truncated, rotated or deleted | Re-copy from the console; check for whitespace and newlines |
403 | Key real, but not entitled to that model or endpoint | Check plan, workspace and model access -- not the key |
404 | Model identifier wrong, or wrong base URL | Confirm the exact model string against the console |
429 | Your quota, not a key problem | Back off with jitter; see the rate-limit guide below |
5xx / timeout | Mistral side. Your key is fine. | Fail over; do not rotate keys mid-incident |
Where the Key Should Live
Leaked AI API keys are not a hypothetical. Public repositories and shipped front-end bundles are scraped continuously, and an exposed key on a funded account can burn a serious bill before the first alert fires.
Server-side only, always
Never call Mistral from a browser or a mobile app. Anything shipped to a client is readable, including values inlined by your bundler. Proxy through a route you control so the key never leaves your infrastructure.
One key per environment and per service
Separate keys for local, staging and production mean a leak is contained and revocation is surgical. A single shared key means every rotation is a coordinated outage.
Git-ignore the .env file, and check history
Adding .env to .gitignore does nothing about a key already committed. Scan history, and treat any key that ever touched a commit as compromised -- rotate rather than hope.
Rotate on a schedule, not on an incident
Create the replacement, deploy it alongside the old one, confirm traffic has moved, then delete the old key. Rotation that starts with deletion is an outage with extra steps.
Stop Pasting Mistral Keys Into .env Files
A shared vault gives every service its own Mistral credential, keeps rotation auditable, and means a departing teammate does not take your only copy of the key with them.
Try 1Password Free →Load the Key Without Leaking It
Most "my key is broken" reports are actually the process never seeing the value. Fail loudly at startup instead of discovering it on the first user request.
const apiKey = process.env.MISTRAL_API_KEY;
if (!apiKey) {
// Fail at boot, not on the first user request
throw new Error('MISTRAL_API_KEY is not set');
}
// Safe to log: proves the value loaded without exposing it
console.log('mistral key loaded:', apiKey.slice(0, 4) + '...' + apiKey.slice(-4), 'len', apiKey.length);
export async function callMistral(body) {
const res = await fetch('https://api.mistral.ai/v1/chat/completions', {
method: 'POST',
headers: { Authorization: `Bearer ${apiKey}`, 'Content-Type': 'application/json' },
body: JSON.stringify(body),
});
if (res.status === 401) throw new Error('Mistral: key rejected - check the value, not the network');
if (res.status === 403) throw new Error('Mistral: key valid but not entitled to this model');
if (res.status === 429) throw new Error('Mistral: rate limited - back off and retry');
if (res.status >= 500) throw new Error('Mistral: provider outage - fail over');
return res.json();
}Logging the length and the first and last four characters is the fastest way to catch a truncated paste or a trailing newline, and it exposes nothing usable.
Billing: What the Key Can Actually Do
Mistral gates key creation behind phone-number verification. That single step is where most first-time setups stall -- the console will happily show you the API Keys screen and then refuse to mint a key until the number is confirmed.
Set a spend alert the same day you create the key. The failure mode nobody plans for is not an outage -- it is a runaway retry loop or a leaked key quietly spending for a week. Full cost mechanics are in our Mistral API pricing guide.
Catch a Broken Mistral Key in Seconds
Continuous checks on your Mistral endpoint surface a 401 after a botched rotation immediately, instead of leaving it to a customer to report.
Try Better Stack Free →Key Problem or Mistral Outage? A 60-Second Check
- Read the status code. 401 and 403 are yours. 429 is quota. 5xx and timeouts are Mistral.
- Print the key length. A value shorter than expected is a truncated copy, not a revoked key.
- Try the cURL above. If cURL works and your app does not, the problem is environment loading.
- Try a second key. If a freshly minted key fails identically, it is not the key.
- Check status.mistral.ai and live Mistral monitoring before touching anything in production.
The full outage-side playbook is in our Is Mistral Down? guide.
Keep a Second Key Warm
A key that gets revoked, leaked or rate limited is an outage if it is your only path to an LLM. Provisioning a second provider's key on day one costs nothing until you use it.
Groq
Independent key and quota. Keep a second provider configured so a key or entitlement problem on Mistral is a reroute, not an outage.
Check Groq status →Together AI
Independent key and quota. Keep a second provider configured so a key or entitlement problem on Mistral is a reroute, not an outage.
Check Together AI status →OpenAI
Independent key and quota. Keep a second provider configured so a key or entitlement problem on Mistral is a reroute, not an outage.
Check OpenAI status →Frequently Asked Questions
How do I get a Mistral API key?
Create a Mistral account, open the Mistral La Plateforme console at console.mistral.ai, and create a new key from the API keys screen. Copy the secret immediately -- it is shown once. Store it in a secret manager or a local .env file as MISTRAL_API_KEY, never in source control, then verify it with a single chat completion request before wiring it into an application.
Is the Mistral API key free?
Mistral gates key creation behind phone-number verification. That single step is where most first-time setups stall -- the console will happily show you the API Keys screen and then refuse to mint a key until the number is confirmed. Either way, creating the key itself costs nothing; what varies between providers is whether the key can do useful work before a payment method exists.
Why is my Mistral API key returning 401?
A 401 from Mistral almost always means the key string itself is wrong: a truncated copy-paste, a stray newline from a shell heredoc, the wrong environment loaded, or a key that was rotated or deleted in the console. Check the raw value your process actually sees before assuming the key is bad -- printing the length and first four characters is usually enough to spot a mangled copy. A 403 is different: the key is real but not entitled to that model or endpoint.
Where should I store my Mistral API key?
In a secret manager or your platform's environment-variable store, injected at runtime as MISTRAL_API_KEY. Never commit it, never ship it to a browser bundle, and never put it in a mobile app -- keys extracted from client-side code are the most common way AI API bills get hijacked. All calls to Mistral should originate from a server you control.
My Mistral key worked yesterday and fails today -- is Mistral down?
Check the status code before you regenerate anything. 401 and 403 are key or entitlement problems. 429 is your own quota. 500, 502, 503 and connection timeouts point at Mistral itself -- confirm on status.mistral.ai or with live Mistral monitoring, because rotating a perfectly good key during an outage just adds a second variable to the incident.
Related Mistral Guides
Know Instantly Whether It Is Your Key or Mistral
API Status Check monitors Mistral and every other provider in your stack, so a bad rotation and a real outage never look the same again.
Start Your Free Trial →Alert Pro
14-day free trialStop checking — get alerted instantly
Next time Mistral goes down, you'll know in under 60 seconds — not when your users start complaining.
- Email alerts for Mistral + 9 more APIs
- $0 due today for trial
- Cancel anytime — $9/mo after trial
🌐 Can't Access Mistral?
If Mistral is working for others but not for you, it might be an ISP or regional issue. A VPN can help bypass network-level blocks and routing problems.
Troubleshoot with a VPN
Connect from a different region to test if the issue is local to your network. Also protects your connection on public Wi-Fi.
Try NordVPN — 30-Day Money-Back GuaranteeSecure Your Mistral Account
Service outages are a common time for phishing attacks. Use a password manager to keep unique, strong passwords for every account.
Try NordPass — Free Password Manager⏳ While You Wait — Try These Alternatives
🛠 Tools We Use & Recommend
Tested across our own infrastructure monitoring 200+ APIs daily
SEO & Site Performance Monitoring
Used by 10M+ marketers
Track your site health, uptime, search rankings, and competitor movements from one dashboard.
“We use SEMrush to track how our API status pages rank and catch site health issues early.”