Docs · Provider

Mistral in Claude Code, Codex, Gemini CLI and OpenCode

Mistral serves its models on one API, OpenAI-style Chat Completions, at api.mistral.ai. Add a Mistral API key to magpie once, and Claude Code, Codex, Gemini CLI, OpenCode and every other agent you connect can use Mistral through magpie’s local gateway at 127.0.0.1:3425, each agent with a model of its own. Agents that speak another API are translated on the way.

Add Mistral

  1. Get a keyMake one on console.mistral.ai. A Le Chat plan’s Vibe key goes in the same provider.
  2. Add the providerIn magpie’s Providers tab, press + Add provider, pick Mistral, paste the key and save. magpie asks Mistral which models the key can use.
  3. Pick it for an agentIn the Agents tab, click the model on the agent’s row and choose a Mistral model such as mistral-large-4.
Terminal
magpie provider add mistral <key>
magpie provider test mistral

Model ids in magpie are provider/model, so Mistral’s read mistral/mistral-large-4: the provider, then Mistral’s own id. The key is kept in magpie’s settings; magpie doesn’t take it from your shell.

Already set Mistral up in OpenCode or Alma? magpie’s import from those apps brings it in as the Mistral provider. An app that keeps one entry per key (“Mistral #0001”, “Mistral #0002”…) becomes one Mistral provider with that many keys, listed once in every agent’s picker.

Endpoints

APIAddressUsed for
Chat Completionshttps://api.mistral.ai/v1the model list and every agent’s requests: OpenCode’s as they are, Claude Code’s, Codex’s and Gemini CLI’s translated
Billinghttps://api.mistral.ai/v1/billing/budget, /v1/billing/subscriptiona key’s month of Vibe or API budget, and the plan it is on

magpie’s Mistral provider has no Anthropic Messages or Responses address, so an agent that speaks either is translated to Chat Completions and the reply translated back, streaming and tool calls included.

Model list

magpie fetches the list from Mistral, at https://api.mistral.ai/v1/models, so agents see the models your key can use. Names, reasoning levels and prices come from models.dev’s mistral catalog, and Devstral, Codestral and Magistral models carry Mistral’s logo in every picker. Mistral also serves models from other labs, such as GLM and DeepSeek’s deepseek-v4.1-flash-1017; they come through the same key, and the fixes below apply to them too. Pick the models agents see in the provider’s model list, or from the terminal:

Terminal
magpie provider models mistral +mistral-large-4 +mistral-medium-3.5
magpie provider refresh-every mistral 1d

In each agent

Terminal
magpie claude mistral/mistral-large-4
magpie codex mistral/mistral-large-4
magpie gemini model mistral/mistral-large-4
magpie opencode mistral/mistral-large-4

What magpie fixes for Mistral

Mistral’s API is strict about what it takes and sends a reasoning model’s thinking in a shape of its own. magpie changes both on the way, on requests it passes on and on those it translates alike:

Reasoning

Mistral’s Chat Completions API doesn’t search the web for magpie, so magpie gives the model its own search tool in every agent, answered by the searcher chosen in Settings, or by one magpie picks when none is chosen.

Vibe, cost and usage

Several keys and failover

One Mistral provider can hold several keys: press Add another key under it, or paste several at once. Requests go to the first key that’s on, and when it runs out or is rate limited the next one takes over.

Terminal
magpie provider spend-cap mistral <key> 20 month
magpie provider key-balance mistral <key> 25
magpie provider fallback mistral deepseek/deepseek-v4-pro

Troubleshooting

FAQ

How do I use Mistral in Claude Code?

Add your Mistral API key in magpie (Providers, Add provider, Mistral), then pick a Mistral model such as mistral-large-4 on Claude Code’s row, or run magpie claude mistral/mistral-large-4. Mistral serves Chat Completions only, so magpie translates Claude Code’s Anthropic Messages requests to https://api.mistral.ai/v1 and the replies back, thinking included.

Can Codex use Devstral and other Mistral models?

Yes. Codex can use any model your Mistral key lists, Devstral among them. Codex speaks OpenAI Responses, which Mistral doesn’t serve, so magpie translates each request to Chat Completions, offers Codex’s custom tools such as apply_patch as functions, and gives the calls back the way Codex runs them.

How do I use Codestral or other Mistral models in OpenCode?

Pick the model in magpie, or run magpie opencode mistral/mistral-large-4; Codestral and Devstral work the same way when your key lists them. OpenCode speaks Chat Completions, so its requests go to Mistral as they are, with what Mistral would refuse fixed on the way: OpenCode’s store field, and earlier turns’ thinking sent back in reasoning_content.

Can Gemini CLI use Mistral?

Yes. Gemini CLI speaks Google’s Gemini API, so magpie translates its requests to Mistral’s Chat Completions and the replies back, streaming and tool calls included. Run magpie gemini model mistral/mistral-large-4.

Why does Mistral answer 422 extra_forbidden?

Mistral turns away any field it doesn’t know. magpie sends an earlier turn’s thinking as the thinking part Mistral takes, leaves out Ollama options some agents add, and asks again without an optional field Mistral names, such as OpenCode’s store, then stops sending it.

Does magpie show my Le Chat plan’s Vibe budget?

Yes. A Vibe key from a Le Chat plan (Pro, Student or Team) shows how much of the month’s Vibe budget is used, in the currency Mistral bills in, and when it resets, with the plan’s name. A Studio key made in the console shows the organization’s API budget instead, as “API · Month”.

By provider: DeepSeek · Kimi and Kimi Code · GLM Coding Plan · Qwen · MiniMax · Gemini · Grok · OpenRouter · GitHub Copilot · Ollama

Every agent: Models in Claude Code, Models in Codex, Models in Gemini CLI, Models in OpenCode. Ask on Discord if you get stuck.