Documentation
¶
Overview ¶
Package mistral provides Mistral AI (La Plateforme, https://api.mistral.ai) integration for the LLM gateway.
Mistral's Chat Completions API is OpenAI-compatible, so chat, models, embeddings, and passthrough go through the shared chat-centric adapter, and the Responses API is translated through chat completions. One wire quirk needs provider-local handling: on reasoning models (Mistral Large 4, Mistral Small 4, and hosted reasoning models such as Z.ai GLM) the assistant message content is not a plain string but a list of typed chunks — {"type":"thinking","thinking":[{"type":"text","text":...}]} for the reasoning trace and {"type":"text","text":...} for the answer — in both the buffered response (choices[].message.content) and the stream (choices[].delta.content). The core chat types reject that shape, and clients expect the standard split, so this package flattens the chunk lists into a string content plus a reasoning_content member (see thinking.go) on both paths.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Registration = providers.Registration{ Type: "mistral", New: New, Discovery: providers.DiscoveryConfig{ DefaultBaseURL: defaultBaseURL, }, }
Registration provides factory registration for the Mistral provider.
Functions ¶
func New ¶
func New(cfg providers.ProviderConfig, opts providers.ProviderOptions) core.Provider
New creates a new Mistral provider.
Types ¶
type Provider ¶
type Provider struct {
*openai.ChatCompatible
}
Provider implements the core.Provider interface for Mistral AI. Transport and the request dialect go through the shared chat-centric adapter's hooks; StreamChatCompletion is overridden only to wrap the stream that flattens Mistral's thinking chunk lists.
func (*Provider) StreamChatCompletion ¶
func (p *Provider) StreamChatCompletion(ctx context.Context, req *core.ChatRequest) (io.ReadCloser, error)
StreamChatCompletion returns Mistral's SSE stream wrapped so that every chunk whose delta.content is a chunk array is rewritten to the standard content + reasoning_content delta shape.
func (*Provider) StreamResponses ¶
func (p *Provider) StreamResponses(ctx context.Context, req *core.ResponsesRequest) (io.ReadCloser, error)
StreamResponses streams a Responses API request through chat-completions translation, picking up the StreamChatCompletion override. Buffered Responses needs no override: the embedded adapter's chat path already applies the response hook.