How to Get a Mistral API Key: A Step-by-Step Guide
On this page
This guide shows you how to get a Mistral API key. You'll create a Mistral account, generate your key, and make your first API call, plus a free alternative for adding Mistral models to your web app.
Prerequisites
- An email address or a Google/GitHub/Microsoft/Apple account
- A payment method — Mistral's API requires an active billing plan
- Basic familiarity with code (we'll show simple JavaScript examples)
Step 1: Create Your Mistral Account
Go to console.mistral.ai. Sign up with your email or use one of the available sign-in options (Google, GitHub, Microsoft, or Apple).
After signing up, you'll be asked to complete your setup by providing an organization name.
Once you're in, you'll land on the dashboard.
Step 2: Generate Your API Key
In the left sidebar, click API keys, then click Create new key.
Give your key a name and set an expiration date, then confirm.
Important: Copy the key immediately. Mistral only shows it once. If you lose it, you'll need to generate a new one.
Store it somewhere safe — a password manager, an .env file, or your platform's secrets manager. Never commit API keys to a public repository.
Step 3: Make Your First API Call
Mistral provides an official client library. Install it first:
npm install @mistralai/mistralai
Then make your first call:
import { Mistral } from "@mistralai/mistralai";
const client = new Mistral({
apiKey: process.env.MISTRAL_API_KEY,
});
const response = await client.chat.complete({
model: "mistral-small-2603",
messages: [{ role: "user", content: "Hello, world!" }],
});
console.log(response.choices[0].message.content);
If you get a response back, everything is working. For the full set of endpoints and parameters, see Mistral's official API docs.
Can You Use the Mistral API for Free?
Creating an API key is free, but using it requires an active billing plan, and the API bills per token. Mistral's developer platform has a free Experiment tier for prototyping. It needs no credit card (phone verification only) and gives rate-limited access to the model lineup, but it is meant for testing rather than production.
Puter.js offers a different model. With its User-Pays model, you can add Mistral models to your app for free: each user covers their own AI usage through their own Puter account, so your cost stays at $0 regardless of how many users you have, with no API key and no backend.
Add Mistral models with the browser script tag:
<script src="https://js.puter.com/v2/"></script>
<script>
puter.ai.chat("Explain quantum computing in simple terms", {
model: "mistralai/mistral-medium-3-5"
}).then(response => {
document.body.innerHTML = response.message.content;
});
</script>
or the npm package:
import { puter } from '@heyputer/puter.js';
const response = await puter.ai.chat("Explain quantum computing in simple terms", {
model: "mistralai/mistral-medium-3-5"
});
console.log(response.message.content);
This fits front-end apps where your users sign into Puter: usage is tied to their accounts, and Puter.js runs in the browser, so it does not replace a server-side key for a backend you control. For a backend, see the pricing below.
How Much Does the Mistral API Cost?
Mistral bills per token, with separate input and output rates. The featured model, Mistral Medium 3.5, is $1.5 per 1M input tokens and $7.5 per 1M output. The cheapest general-purpose model, Mistral Small 4, is $0.1 input and $0.3 output, and Ministral 3 3B runs $0.1 in and out for edge workloads. Batch processing takes 50% off the per-token rates.
For the full breakdown, see our Mistral API pricing guide.
Why Isn't My Key Working?
Most first-call failures trace back to a few errors:
- 401, authentication_error: the key is wrong, expired, or picked up a stray space or newline when copied. Regenerate it and paste again.
- 403, Forbidden: the key is valid but the workspace has no active billing plan, or the key lacks access to that model or endpoint. Activate billing and check the key's permissions.
- 429, rate_limit_error: requests are going out faster than your tier allows. Add retries with exponential backoff, or raise your limits.
- 422, validation error: the request body failed validation, often a misspelled or unavailable model name. Check the model ID against the docs.
- 400, invalid_request_error: the request is otherwise malformed, such as a missing or wrongly formatted field.
Most new-key failures come back to billing not being active, so check that first. For the full list of status and error codes, see Mistral's error codes reference.
Conclusion
To get a Mistral API key: sign up at console.mistral.ai, add a payment method, then go to API keys and click Create new key. From there you can make your first API call, or skip the key entirely and add Mistral models to a web app for free with Puter.js.
Related
- Mistral API Pricing
- Free, Unlimited Mistral API
- Free, Unlimited Claude API
- How to Get an OpenAI API Key
- How to Get an Anthropic (Claude) API Key
- How to Get a Gemini API Key
- How to Get a DeepSeek API Key
- How to Get an ElevenLabs API Key
- How to Get a Grok (xAI) API Key
- How to Get a MiniMax API Key
- How to Get a Moonshot AI (Kimi) API Key
- How to Get a Qwen API Key
- How to Get a Z.AI (GLM) API Key
- How to Get an OpenRouter API Key
- How to Get a FLUX (Black Forest Labs) API Key
- How to Get a Stability AI (Stable Diffusion) API Key
- How to Get a Kling API Key
- How to Get a Leonardo.Ai API Key
- How to Get a Together AI API Key
- How to Get a Cohere API Key
- How to Use OpenAI SDK with Puter
- Free, Unlimited OpenAI API
- Free, Unlimited Gemini API
- How to Use LangChain with Puter
- How to Use Vercel AI SDK with Puter
Ship a Full-Stack App with One Prompt
Build an AI chat app using Puter.js
Coding manually? see the guide