feat(llm): add built-in Mistral AI provider preset - #781
Merged
lizhengfeng101 merged 1 commit intoAug 8, 2026
Conversation
Add Mistral AI to the provider registry using the existing OpenAI-compatible chat completions protocol. Mistral's endpoint at https://api.mistral.ai/v1 speaks the same request/response shape, so no client code or new protocol constant is required — this is a registry-only addition matching the pattern established by the recently merged Eden AI (alibaba#346), Ollama Cloud (alibaba#375), and LiteLLM (alibaba#385) provider presets. Auth via MISTRAL_API_KEY. Curated model list kept deliberately minimal (codestral-latest, mistral-large-latest, mistral-small-latest); users can select any other Mistral model via `ocr config set model <name>`. Tested end-to-end against api.mistral.ai with codestral-latest against a staged diff — review returned an accurate high-severity SQL injection finding with a correct parameterized-query fix suggestion.
Contributor
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 1 selected item(s). |
xavierpestel-ai
marked this pull request as ready for review
August 7, 2026 21:49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Draft companion to #780. Not requesting review until maintainers confirm the direction on the discovery issue. Opened as a draft so the concrete diff is available for inspection alongside the proposal.
Description
Adds Mistral AI as a built-in LLM provider preset, so that users would be able to select it with:
Design
Mistral's Chat Completions endpoint at
https://api.mistral.ai/v1is OpenAI-compatible (verified — see the testing section below), so this is a registry-only addition using the existingProtocolOpenAIChatCompletions. It mirrors the pattern of the recently merged provider presets: Eden AI (#346), Ollama Cloud (#375), and LiteLLM (#385).Scope guardrails
No changes to any of:
internal/llm/client.gointernal/llm/protocol.gointernal/llm/resolver.gocmd/opencodereview/config_cmd.gocmd/opencodereview/provider_cmd.goaction.ymlgo.mod/go.sumThe diff is one new entry in
internal/llm/providers.goand one new test ininternal/llm/providers_test.go. Total: 52 additions, 1 deletion.Model list rationale
Kept deliberately minimal — the preset only seeds the interactive picker; users can select any Mistral model via
ocr config set model <name>.codestral-latestmistral-large-latestmistral-small-latestDisclosure
I work at Mistral AI. This is a personal contribution submitted under the same preset pattern as PRs #346, #375, #385.
Type of Change
How Has This Been Tested?
make testpasses locallyLocal verification
make check(license, gofmt, go vet, go mod tidy)go test -race ./internal/llm/TestLookupProvider_MistralDetails(new)TestListProviders_Order(updated to includemistralin sorted position)TestProviders_AllProtocolsCanonicalmake buildinternal/llmcoverageproviders.goLive smoke test against
api.mistral.aiPOST https://api.mistral.ai/v1/chat/completionswith an OpenAI-shape request body returned an OpenAI-shape response containingid,object,created,model,choices[0].message.{role,content},finish_reason,usage.{prompt_tokens,completion_tokens,total_tokens}, andtool_calls. The existingOpenAIClientparses this without modification.End-to-end
ocr reviewagainst MistralBuilt the
ocrbinary with this change, setprovider=mistral, model=codestral-latest, ranocr reviewon a scratch git repo whose staged diff introduced a SQL injection (db.Exec("DELETE FROM users WHERE id = " + id)). The review produced a single finding at the correct line with severitysecurity · highand a parameterized-query suggested fix. Command exited cleanly.Paths not exercised
To be transparent about what was and was not verified:
codestral-latestwas exercised end-to-end.mistral-large-latestandmistral-small-latestwere only exercised at the registry-lookup level.Checklist
go fmt,go vet)Related Issues
Companion to #780 (direction check). Do not auto-close on merge — #780 is for direction confirmation, not a bug to close.