Mistral coding agent: API key, models and setup
Updated Fact-checked
To set up a Mistral coding agent, create an API key in the Mistral console and give it to your agent. Mistral’s own agent, Vibe, signs in with your Mistral account or a key. OpenCode has Mistral built in, Codex CLI takes it as a custom provider, and Contenox Harness takes the key too. Claude Code can’t use Mistral models.
Use Mistral with your agent#
| Agent | Supported? | How | Note |
|---|---|---|---|
| Claude Code | No | Claude Code runs Claude models only, through Anthropic, Amazon Bedrock, Google Cloud’s Agent Platform (Vertex AI) or Microsoft Foundry. Anthropic doesn’t support routing it to other models. | |
| Codex CLI | Yes | [model_providers.mistral] in ~/.codex/config.toml |
Codex uses Mistral’s Responses API, which is in public preview. |
| OpenCode | Yes | /connect → Mistral → paste the key |
Also reads MISTRAL_API_KEY. |
| Mistral Vibe | Yes | vibe, then sign in in the browser or paste a key |
Mistral’s own agent, in the terminal and VS Code. |
| Contenox Harness | Yes | Backends → Providers → More providers → Mistral |
Which plan or key do I need?#
Two things are easy to mix up:
- The API. You create keys in the Mistral console.
- Mistral’s plans (Free, Pro, Team, Enterprise and others). Each plan’s monthly usage is shared across Studio, the API and Vibe; pay-as-you-go can extend it. Mistral’s pricing page says Pro includes Vibe coding and a monthly amount of API credit.
Your organization’s current limits are in the console under Admin Panel → API → Limits. An organization can also set a monthly spending limit; when it is reached, API access stops until the next month or until an admin raises it.
Mistral Vibe#
On macOS or Linux:
curl -LsSf https://mistral.ai/vibe/install.sh | bash
vibe --version
For Windows, follow the Windows tab in Mistral’s install guide.
Run vibe in your project. The first-run wizard offers Launch browser, which signs
you in with your Mistral account and plan, or an API key, which it stores in your system
keyring or ~/.vibe/.env. vibe --setup runs the wizard again.
OpenCode#
In the OpenCode terminal, enter /connect, select Mistral, and enter your Mistral API key. Choose a model with /models. OpenCode install options · Provider setup
Codex CLI#
Add the provider to ~/.codex/config.toml in your user folder. Replace the model with an
API model ID from Mistral’s models list:
model = "YOUR_MISTRAL_MODEL_ID"
model_provider = "mistral"
[model_providers.mistral]
name = "Mistral"
base_url = "https://api.mistral.ai/v1"
env_key = "MISTRAL_API_KEY"
Set the key, then open a new terminal and run codex. Windows PowerShell:
setx MISTRAL_API_KEY "your-key-here"
macOS or Linux:
export MISTRAL_API_KEY=your-key-here
The preview gotcha: Codex only speaks the OpenAI Responses API to custom providers, and Mistral’s Responses API is still in public preview. If a feature breaks, that is the first place to look.
Which Mistral model should I pick?#
An agent needs a chat model that calls tools reliably. From Mistral’s current models list:
- Mistral Large 4: the general-purpose flagship. Start here for changes across several files.
- Mistral Small 4: combines instruction following, reasoning and coding in a smaller, cheaper model. Good for routine edits.
- Codestral: built for code completion as you type, not for running an agent. Skip it.
Mistral’s API also serves some third-party open-weight models, such as GLM and DeepSeek models. Try any model on a small task in your project before you trust it with a large one.
Common errors#
- Key rejected or 401: the key is wrong or was deleted. Create a new one in the console.
- 429 Too Many Requests: you hit a rate limit. Wait and try again, and check your limits under Admin Panel → API → Limits.
- Requests stop until next month: your organization reached its monthly spending limit. An admin can raise it.
Other ways to run Mistral models#
- Open weights: Mistral publishes models such as Mistral Small 4 and Ministral 3 under open licenses. You can run open-weight models on your own machine with Ollama if your hardware allows; check the Ollama library for the exact model first.
- AWS Bedrock offers some Mistral models, billed to your AWS account. See AWS Bedrock.
Contenox Harness#
Contenox Harness takes the same key and lets you switch between Mistral and other providers per session.
- Open Backends → Providers, then More providers, and choose Mistral.
- Select Create key, create a key in the Mistral console and copy it.
- Paste it into API Key, select Connect and wait for Connected.
- Pick a model in the Model chip on the message box.
To keep the key out of the app, enter MISTRAL_API_KEY under Advanced in
Environment variable name, set it with setx MISTRAL_API_KEY "your-key-here", and
reopen Contenox Harness. If the status shows Key rejected, use Replace to paste a new key.
Related#
How to choose a model for codingHow to compare AI coding models on your own codebaseCompare AI coding models on five tasks from your repository. Score each run on passing tests, unnecessary edits, elapsed time and cost per finished task.
Run models locallyLocal AI coding agent: Claude Code, Codex, OpenCode setupRun a local AI coding agent on your own hardware: Ollama or vLLM, setup for Claude Code, Codex CLI and OpenCode, memory needs, and models that call tools.
OllamaSet up an Ollama coding agent on Windows, Mac or LinuxSet up an Ollama coding agent in Contenox on Windows, macOS or Linux. Install Ollama, download a chat model, check the connection and send your first message.
AWS BedrockAWS Bedrock coding agent: Claude Code, Codex, OpenCodeRun an AWS Bedrock coding agent: setup for Claude Code, Codex CLI and OpenCode, the IAM permissions and model access it needs, and AccessDenied fixes.
OpenRouter: one key for many model makersOpenRouter coding agent: Claude Code, Codex, OpenCode setupUse OpenRouter with a coding agent: setup for Claude Code, Codex CLI and OpenCode, a capped API key, models that call tools well, and 401 and 402 fixes.
ChatGPT subscriptionUse your ChatGPT subscription for a coding agent | ContenoxUse your ChatGPT subscription for a coding agent. Set up device sign-in in Contenox or use Codex on desktop, in an editor or in the terminal. Check plan limits.
GitHub Copilot subscriptionUse your GitHub Copilot subscription in other coding agentsUse your GitHub Copilot subscription outside VS Code: sign-in steps for OpenCode, Codex and Contenox Harness, which plans you need, and how AI Credits are billed.
Anthropic (Claude)Claude coding agent on Windows: API key setup | ContenoxRun a Claude coding agent on Windows: Claude Code with a subscription or API key, OpenCode with a key, why Codex can't, plus models, billing and key errors.
GeminiGemini coding agent: API key, free tier and setup | ContenoxSet up a Gemini coding agent: AI Studio key in OpenCode, Antigravity CLI or Contenox Harness, why Claude Code and Codex can't, free-tier data use, models and 429 fixes.