Setup guide - Documented by OpenCode
Use Mistral in OpenCode
OpenCode's provider docs have no dedicated Mistral section, but they document a Custom provider for any OpenAI-compatible API using @ai-sdk/openai-compatible. Mistral documents its OpenAI-compatible base URL, https://api.mistral.ai/v1. Combine the two: store the key with /connect > Other, then declare the provider and Mistral model ids in opencode.json.
Last verified 4 steps4 official sources
Steps
- Step 1.
Run /connect, scroll down to Other, enter a unique provider id (the docs say you will reuse it in your config file), then paste your Mistral API key.
Terminal$ /connect ┌ Add credential │ ◆ Select provider │ ... │ ● Other └ - Step 2.
Create or update opencode.json in your project directory. This is the docs' custom-provider template with Mistral's documented base URL and model ids filled in. The provider id must match the one you entered in /connect.
JSON{ "$schema": "https://opencode.ai/config.json", "provider": { "mistral-api": { "npm": "@ai-sdk/openai-compatible", "name": "Mistral", "options": { "baseURL": "https://api.mistral.ai/v1" }, "models": { "mistral-medium-latest": { "name": "Mistral Medium 3.5" }, "codestral-latest": { "name": "Codestral" } } } } } - Step 3.
Optionally load the key from an environment variable instead of /connect, using the docs' {env:...} syntax for options.apiKey.
JSON"apiKey": "{env:MISTRAL_API_KEY}" - Step 4.
Run /models. Your custom provider and its models appear in the selection list.
Snippet/models
Caveats
- This combines OpenCode's documented Custom provider config with the base URL from Mistral's migration guide and model ids from Mistral's Models Overview. OpenCode's docs do not show Mistral specifically.
- The provider id mistral-api is an example name chosen here. The docs only require a unique id that matches the one entered in /connect.
- OpenCode says it supports 75+ providers through Models.dev, so Mistral may also appear directly in /connect. The providers page has no Mistral section to confirm that.
- Per OpenCode's docs, @ai-sdk/openai-compatible targets /v1/chat/completions, which is the endpoint Mistral documents.
- Mistral Medium 3.5 has a 256k context window per Mistral's docs. Standard providers pull limits from models.dev; for a custom provider, set limit.context and limit.output yourself if you need OpenCode to track context.
- Devstral 2 (devstral-2512, devstral-latest) was retired 2026-07-31 and replaced by mistral-medium-3-5.
More setup guides
Same tool, other providers
Related reading
- Mistral Large 4: Specs, Pricing, Benchmarks and Weights DateMistral Large 4 is a 1T-parameter multimodal MoE with 52B active, in public preview at $0.68/$2.09 per million tokens, with open weights due end of October.
- Mistral Shieldstral: A 3B Open-Weight Policy-Adaptive Moderation Model That Beats Models 7x Its SizeMistral Shieldstral is a 3B Apache 2.0 multimodal moderation model that takes your policy as a plain-language question at inference and runs on one 16GB GPU.
- Mistral Releases Robostral Navigate: An 8B Robotics Navigation ModelMistral Robostral Navigate is an 8B robotics model that navigates with only a camera and natural language commands. How it works and what the benchmarks mean.
- Leanstral 1.5: Mistral's Open Theorem-Proving Model Hits 100% on miniF2FLeanstral 1.5 is Mistral's open Apache-2.0 model for Lean 4 theorem proving. The benchmark claims, the HN pushback on its bug-finding pitch, and how to use it.
- Mistral OCR 4 and Unlimited OCR Make Document Parsing an Agent Runtime ChoiceMistral OCR 4 and Baidu's Unlimited OCR turn document parsing into a runtime choice for agents - cost per page, layout, confidence scores and self-hosting.
- Codex Custom Model Providers: GLM-5.3, Mistral and OllamaCodex only speaks the Responses API now. Tested config.toml blocks for GLM-5.3, Mistral Large 4 through a gateway, local Ollama and an internal proxy.
FAQ
How do I use Mistral in OpenCode?
OpenCode's provider docs have no dedicated Mistral section, but they document a Custom provider for any OpenAI-compatible API using @ai-sdk/openai-compatible. Mistral documents its OpenAI-compatible base URL, https://api.mistral.ai/v1. Combine the two: store the key with /connect > Other, then declare the provider and Mistral model ids in opencode.json.
Which Mistral model ids work in OpenCode?
The official docs read for this guide list mistral-medium-3-5, mistral-medium-latest, mistral-small-2603, mistral-small-latest, codestral-2508 and codestral-latest. Requests go to https://api.mistral.ai/v1.
Is this an official Mistral and OpenCode setup?
OpenCode documents this setup in its own docs. It was last checked against 4 official pages on October 17, 2026.
Sources
Last verified against 4 official pages.
- github.comhttps://github.com/sst/opencode/blob/dev/packages/web/src/content/docs/providers.mdx
- opencode.aihttps://opencode.ai/docs/providers/
- docs.mistral.aihttps://docs.mistral.ai/resources/migration-guides
- docs.mistral.aihttps://docs.mistral.ai/models
Newsletter
New models, set up the day they ship
One email per week. New model releases, the coding tools that support them and how to wire them up.