# Mistral AI API keys: find, store, rotate, and use them safely with AI agents

Source: https://botpassword.com/keys/mistral
Last checked: 2026-11-08

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.

## Key types

| Type | Prefix | Secret | Scope | Expiry |
|---|---|---|---|---|
| API key | — | 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

1. Open the Studio console at `console.mistral.ai` and go to **API keys**.
2. Select the target workspace from the workspace dropdown.
3. Click **Create new key**.
4. Enter a name, set an expiration date and choose a connector access scope.
5. 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.

## 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

1. Create a new key in the same workspace, with an expiration date.
2. Switch your code and secret stores to the new key.
3. Delete the old key in **Studio › API keys**, or in **Admin Panel › API › API Keys** as an Organization Admin.

## How to revoke a Mistral AI key

1. Open **API keys** in Studio (or **API Keys** from your user profile menu) and delete the key.
2. Organization Admins can delete any member's key from **Admin Panel › API › API Keys**.
3. On Enterprise plans, the Admin API deletes a key with `DELETE /v1/admin/api-keys/{key_id}`.

## If the key leaked

1. Delete the exposed Mistral API key immediately; it stays valid until deleted or expired.
2. Create a replacement key with a short expiration date and deploy it.
3. Check the key list's **last used** date and the workspace's usage and billing for activity you do not recognise.
4. Set or lower spending limits under **Admin Panel → Subscriptions → Billing**.
5. Turn on GitHub push protection; GitHub secret scanning detects Mistral AI API keys before they are pushed.

## Environment variables

- `MISTRAL_API_KEY`

## Gotchas

- 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.

## Using this key with AI agents (BotPassword)

- `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.

## FAQ

### 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.

## Sources

- https://docs.mistral.ai/getting-started/quickstarts/developer/first-api-request
- https://docs.mistral.ai/getting-started/quickstarts/admin/manage-workspaces
- https://docs.mistral.ai/getting-started/quickstarts/studio/activate-and-generate-api-key
- https://docs.mistral.ai/admin/identity-access/api-keys
- https://docs.mistral.ai/api/endpoint/beta/admin/api-keys
- https://docs.github.com/en/code-security/secret-scanning/introduction/supported-secret-scanning-patterns
