feat(models): add Mistral AI as a native LLM provider - #2406
feat(models): add Mistral AI as a native LLM provider#2406xavierpestel-ai wants to merge 2 commits into
Conversation
Adds Mistral AI as a first-class provider across the Go controller, Go ADK runtime, Python ADK runtime, and UI. Mistral speaks the OpenAI-compatible wire protocol, so the runtime reuses the OpenAI SDK client internally with a Mistral base URL and MISTRAL_API_KEY env var — no new HTTP transport, no new SDK dependency. New surfaces: - v1alpha2 CRD: Mistral enum + MistralConfig (baseUrl, temperature, topP, maxTokens, timeout) + CEL rule + default endpoint https://api.mistral.ai/v1 - Controller translator: injects MISTRAL_API_KEY from Secret - Go ADK: adk.Mistral type + models.MistralModel (wraps OpenAIModel) - Python ADK: KAgentMistralLlm subclassing BaseOpenAI - Env vars: MISTRAL_API_KEY, MISTRAL_API_BASE - Telemetry: gen_ai.provider.name=mistral_ai - Model catalog: 10 Mistral models (mistral/magistral/codestral/ministral/ pixtral/nemo latest tags) - UI: Mistral provider entry + icon + combobox wiring - Helm values: providers.mistral entry (default provider unchanged) - Docs: providers.md Mistral section - Tests: Go/Python unit tests, CEL admission tests, translator golden test, e2e mock-server test (gated on MISTRAL_API_KEY) Signed-off-by: Xavier Pestel <xavier.pestel@mistral.ai>
c5a96c8 to
75c7a22
Compare
|
First off, thanks so much for the PR :) If the wire protocol is the same as OpenAI I'm wondering if we really need a whole new API block for this? Typically we allow usage of chat completions compatible APIs via BaseURL. I definitely see value in adding a mistral block to the UI and website, so it's clearer there that Mistral is supported, but I'm not sure it's worth adding the block to the API. What do you think? |
Hi. Yes it's just a proposition. Yes Mistral is openai compatible so it does the job like that (I already did a video to show Mistral Inference with kagent). We can close the PR no worries. |
Summary
Adds Mistral AI as a first-class LLM provider across the Go controller, Go ADK runtime, Python ADK runtime, and UI. Mistral speaks the OpenAI-compatible wire protocol (POST
/chat/completionswith a Bearer token athttps://api.mistral.ai/v1), so both runtimes reuse the OpenAI SDK client internally — no new HTTP transport, no new SDK dependency.Changes
CRD (v1alpha2)
Mistralprovider enum value +MistralConfigstruct (baseUrl,temperature,topP,maxTokens,timeout)mistralis nil for non-Mistral providershttps://api.mistral.ai/v1zz_generated.deepcopy.goand CRD manifests in bothgo/api/config/crd/bases/andhelm/kagent-crds/templates/Controller translator
Mistralcase intranslateModel()— injectsMISTRAL_API_KEYfrom Secret into the agent podGo ADK runtime
adk.Mistraltype +models.MistralModel(wrapsOpenAIModelinternally)CreateLLM()ingo/adk/pkg/agent/agent.goPython ADK runtime
KAgentMistralLlmclass subclassingBaseOpenAI(hardcodes Mistral base URL +MISTRAL_API_KEYenv fallback)ModelUnionPydantic discriminatorEnv vars, telemetry, catalog
MISTRAL_API_KEY,MISTRAL_API_BASEgen_ai.provider.name=mistral_aimistral-large-latest,mistral-medium-latest,mistral-small-latest,magistral-medium-latest,magistral-small-latest,codestral-latest,ministral-8b-latest,ministral-3b-latest,pixtral-large-latest,open-mistral-nemo(all with function calling)UI
Mistraladded toBackendModelProviderType,modelProviders,PROVIDERS_INFOui/src/components/icons/Mistral.tsx)ModelProviderComboboxandProviderComboboxicon mapsHelm
providers.mistralentry invalues.yaml. Default provider unchanged.Docs
.claude/skills/kagent/references/providers.md(Helm keys, env vars, CLI examples, ModelConfig YAML)Example ModelConfig
Set
MISTRAL_API_BASEto point at a self-hosted or regional Mistral endpoint.Testing
All test suites green (evidence):
go/apiunit testsgo/adkunit testsTestNewMistralModelWithLogger(7 cases) +TestMistralModel_NamePropagatesModelNotProvidergo/coreunit tests (non-e2e)TestGoldenAdkTranslator/mistral_agentgolden testTestCreateLLMConfig_Mistral(agent_test.go)test_mistral.pytest_mistral.py+test_openai.py+test_anthropic.pyTestE2EInvokeWithMistralAgentMISTRAL_API_KEYunset (verified). Modeled onfoundry_test.go, uses a mock OpenAI-compatible server — never contacts the real Mistral APImake -C go generate+make -C go manifests+make controller-manifestsnpx tsc --noEmitgo vet ./...Pre-existing issues observed (not fixed here)
golangci-lintfails to loadbin/kube-api-linter.sodue to a Go runtime version drift in the vendored plugin. Unrelated to this PR (go vetis clean).test_tls_e2e.pyfailures exist onmain(verified viagit stash+ rerun). Unrelated to Mistral.Not in this PR
EmbeddingConfigtype does not discriminate on provider the same wayModeldoes. Mistral embeddings (mistral-embed) is a straightforward follow-up but is not scoped here.Type:
feat(Conventional Commits).