Quickstart: create your first API key
In this quickstart, you create an API key in Studio›Studio ↗, store it in an environment variable, and send a test request with it. It takes about 5 minutes. The other Studio quickstarts start from this key.
Before you begin
- A Mistral account ↗ on a plan with API access — see Set up billing to add a payment method.
curl, to send the test request.
1. Create the key
- Open the Studio console and go to
API Keys(direct link). - Select
New key.

- Enter a
Namethat identifies the key, for examplequickstart. - Set an
Expirationdate. - Choose a
Connector access scope:Shared connectors only: access only Connectors shared with the Workspace, not your private Connectors.Private and shared connectors: access both your private Connectors and the Connectors shared with the Workspace.

The full key appears only once. You can't retrieve it after you close the confirmation dialog.
- Create the key, then copy it and store it in a password manager or a secrets vault.
2. Store the key in an environment variable
MISTRAL_API_KEY environment variable. Set it in your terminal:
export MISTRAL_API_KEY="your-api-key"The variable lasts for the current terminal session.
3. Send a test request
Send a chat completion request with the key:
curl https://api.mistral.ai/v1/chat/completions \
-H "Authorization: Bearer $MISTRAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "mistral-small-latest",
"messages": [{"role": "user", "content": "Hello, Mistral!"}]
}'You should see
A JSON response with the model's reply in choices[0].message.content. The reply text varies between runs. The response also includes id, created, and usage.
{
"object": "chat.completion",
"model": "mistral-small-latest",
"choices": [
{
"index": 0,
"finish_reason": "stop",
"message": {
"role": "assistant",
"content": "Hello! How can I assist you today?"
}
}
]
}If you get {"detail":"Invalid API Key"} with HTTP status 401, check that MISTRAL_API_KEY holds the full key, in the terminal where you run curl.
Set an expiration date on every key and rotate keys regularly: create a new key, switch your code to it, then delete the old one. Delete a key as soon as you stop using it or suspect it has leaked. If an admin manages API keys for your organization, see API keys in the Admin docs.