Mistral API keys are created in the Studio console under API keys (console.mistral.ai/api-keys). Each Mistral API key belongs to one workspace, has the expiration date you set, and is shown only once. The SDKs read the key from MISTRAL_API_KEY, and API access is on by default in Free mode with no credit card.
Mistral AI key types
| Type | Prefix | Secret? | Scope | Expiry |
|---|---|---|---|---|
| API key Usage and billing are tracked per workspace. | — | Yes | One workspace, using that workspace's quota, rate limits and resources; a connector access scope of **Shared connectors only** or **Private and shared connectors** | You set an expiration date when creating the key; organization and workspace policies can cap it |
How to create a Mistral AI key
- Open the Studio console at
console.mistral.aiand go to API keys. - Select the target workspace from the workspace dropdown.
- Click Create new key.
- Enter a name, set an expiration date and choose a connector access scope.
- Click Create new key and copy the key immediately. Mistral shows the full key only once and it cannot be retrieved after the dialog closes.
Open Mistral AI's key settings
Limiting what the key can do
Mistral API keys are scoped to the workspace where they were created, so Mistral recommends separate workspaces for development, staging and production. The connector access scope limits a key to connectors shared with the workspace, or also your private connectors. Workspace roles apply (Admin has full control including keys; Member can use API keys), and spending limits are under Admin Panel → Subscriptions → Billing.
How to rotate a Mistral AI key
- Create a new key in the same workspace, with an expiration date.
- Switch your code and secret stores to the new key.
- Delete the old key in Studio › API keys, or in Admin Panel › API › API Keys as an Organization Admin.
The old and new Mistral API keys both work until the old key is deleted or reaches its expiry. Expiration policies are off by default; when an Organization Admin sets a maximum validity (and a Workspace Admin a stricter one), it applies to new keys, and existing keys keep working until revoked or expired.
How to revoke a Mistral AI key
- Open API keys in Studio (or API Keys from your user profile menu) and delete the key.
- Organization Admins can delete any member's key from Admin Panel › API › API Keys.
- On Enterprise plans, the Admin API deletes a key with
DELETE /v1/admin/api-keys/{key_id}.
If your Mistral AI key leaked
- Delete the exposed Mistral API key immediately; it stays valid until deleted or expired.
- Create a replacement key with a short expiration date and deploy it.
- Check the key list's last used date and the workspace's usage and billing for activity you do not recognise.
- Set or lower spending limits under Admin Panel → Subscriptions → Billing.
- Turn on GitHub push protection; GitHub secret scanning detects Mistral AI API keys before they are pushed.
Environment variables and CLI
Mistral AI's SDKs and docs read the key from MISTRAL_API_KEY.
Things that catch people out
- The full Mistral API key is shown only once, at creation.
- Mistral API keys are tied to a workspace, so a key from another workspace uses that workspace's quota and billing.
- Expiration policies only apply to new keys; older non-expiring keys keep working until someone deletes them.
Common Mistral AI authentication errors
Invalid API Key
HTTP 401 with {"detail":"Invalid API Key"}. The key is missing, incomplete, expired or deleted.
Using your Mistral AI key with AI agents
A coding agent that can read your .env file or your shell history can read the key, and anything in its context can end up in logs, transcripts or a prompt-injected request. The safer pattern is to keep the key in a credential broker that performs the authenticated step for the agent and hands back only the result.
BotPassword works this way. For a Mistral AI key, these intents fit:
| Intent | What BotPassword does |
|---|---|
run_with | Runs a command with the key injected as an environment variable or a 0600 temporary file, never on the command line, and redacts the key from the output. |
http_request | Makes an authenticated API call after checking the destination against the hosts this key may be sent to. The response comes back with credential-shaped values redacted, and one that holds the key itself is refused. |
store_secret | Saves a value the agent already holds as a new vault item. |
capture_secret | Planned, not built yet: will read a newly created key straight from the page or command output into the vault. |
Set it up in your agent: Aider · Amp · Claude Code · Claude Desktop · Cline · OpenAI Codex CLI · all agents
Frequently asked questions
Where do I get a Mistral API key?
In the Studio console at console.mistral.ai/api-keys, pick a workspace and click Create new key.
Is the Mistral API free?
Mistral's docs say API access is enabled by default in Free mode, with no credit card required, and usage and rate limits apply.
What environment variable does the Mistral SDK use?
Mistral's SDKs and examples read MISTRAL_API_KEY.
Do Mistral API keys expire?
Mistral API keys expire on the date you set when creating them. Organization and workspace admins can enforce a maximum validity for new keys.
How do I delete a leaked Mistral API key?
Delete it in Studio › API keys, or ask an Organization Admin to delete it in Admin Panel › API › API Keys, then create a replacement.
Can an AI agent use my Mistral AI key without seeing it?
Yes, if the key never enters the agent's context. Instead of pasting the key into a chat or leaving it in a .env file the agent can read, keep it in a credential broker that injects it into the command or request on the agent's behalf. BotPassword does this with run_with, http_request, store_secret, so the agent gets the result and never the value.