- Getting started
- Quickstarts
- Studio quickstarts
Quickstart: create your first API key
Quickstart: create your first API key
In this quickstart, you create an API key in 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
1.
Open the Studio console and go to API Keys (direct link).2.
Select New key.

1.
Enter a Name that identifies the key, for example quickstart.2.
Set an Expiration date.3.
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.
1.
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
The Mistral SDKs and the examples in these docs read the key from the 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.
Next quickstarts
Quickstart: send your first API request
Install the Mistral SDK and get your first answer from a Mistral model in Python, TypeScript, or curl, in about 5 minutes.
5 min to complete
Quickstart: compare models in the playground
Send a prompt to a Mistral model in the Studio playground, change a parameter, and compare two models, in about 5 minutes.
5 min to complete
Quickstart: build your first workflow
Scaffold a workflows project, run a worker on your machine, and get the result of your first execution, in about 15 minutes.
15 min to complete
Going further
All quickstarts
Find a short, hands-on quickstart for Vibe Work, Vibe Code, Studio, inference, or Admin, and complete your first task.