← Back to PRs

#16258: feat(models): add Mistral AI provider support

by joeVenner open 2026-02-14 14:54 View on GitHub →
docs agents size: S
## Pull Request Description ### Summary Adds native support for **Mistral AI** as a model provider. Users can now use Mistral models directly by setting the `MISTRAL_API_KEY` environment variable or configuring the provider in their OpenClaw config. ### Models Added | Model ID | Name | Context Window | Input Types | Pricing (per 1M tokens) | |----------|------|----------------|-------------|------------------------| | `mistral-large-latest` | Mistral Large | 128K | text, image | $2.00 input / $6.00 output | | `mistral-medium-latest` | Mistral Medium | 128K | text | $0.40 input / $1.20 output | | `mistral-small-latest` | Mistral Small | 128K | text | $0.10 input / $0.30 output | | `codestral-latest` | Codestral | 256K | text | $0.30 input / $0.90 output | | `ministral-8b-latest` | Ministral 8B | 128K | text | $0.10 input / $0.30 output | ### Usage **Option 1: Environment Variable** ```bash export MISTRAL_API_KEY="your-api-key" openclaw agent --model mistral/mistral-large-latest ``` **Option 2: Configuration** ```json { "models": { "providers": { "mistral": { "apiKey": "your-api-key" } } }, "agents": { "defaults": { "model": { "primary": "mistral/mistral-large-latest" } } } } ``` ### Changes - **`src/agents/models-config.providers.ts`**: - Added Mistral base URL and pricing constants - Added `buildMistralProvider()` function with 5 models - Added Mistral to `resolveImplicitProviders()` for auto-discovery ### Related - Mistral tool call ID sanitization (`strict9` mode) was already supported in `transcript-policy.ts` - `MISTRAL_API_KEY` environment variable mapping was already in `model-auth.ts` ### Testing - [x] Verify `MISTRAL_API_KEY` environment variable is detected - [x] Verify models appear in `openclaw models list` - [x] Test model selection with `mistral/mistral-large-latest` - [x] Verify tool call ID sanitization works correctly <!-- greptile_comment --> <h3>Greptile Summary</h3> Adds native Mistral AI provider support with 5 models (`mistral-large-latest`, `mistral-medium-latest`, `mistral-small-latest`, `codestral-latest`, `ministral-8b-latest`). The implementation follows established provider patterns in the codebase and integrates with existing Mistral infrastructure (env var mapping in `model-auth.ts`, tool call ID sanitization in `transcript-policy.ts`). - Defines `buildMistralProvider()` with OpenAI-compatible API, pricing tiers, and correct context windows (128K default, 256K for Codestral) - Registers Mistral in `resolveImplicitProviders()` for auto-discovery via `MISTRAL_API_KEY` env var or auth profiles - Includes an unrelated change in `src/browser/csrf.ts` that adds an explicit return type annotation to `browserMutationGuardMiddleware()` - Minor typo in the pricing URL comment (`la-plateprise` → `la-plateforme`) <h3>Confidence Score: 4/5</h3> - This PR is safe to merge — it adds a new provider following well-established patterns with no impact on existing functionality. - The Mistral provider implementation closely mirrors existing providers (NVIDIA, Together, etc.) in both structure and registration flow. The codebase already had Mistral support infrastructure (env var mapping, tool call ID sanitization) in place. The only notable issue is a typo in a comment URL. The unrelated csrf.ts change is a safe type annotation addition. - No files require special attention. The `src/browser/csrf.ts` change is unrelated to the PR scope but is harmless. <sub>Last reviewed commit: bc1713a</sub> <!-- greptile_other_comments_section --> <sub>(5/5) You can turn off certain types of comments like style [here](https://app.greptile.com/review/github)!</sub> <!-- /greptile_comment -->

Most Similar PRs