Skip to main content

Module convert

Module convert 

Source
Expand description

Conversion between framework types and the Mistral chat-completions wire format.

Mistral’s POST /v1/chat/completions endpoint is wire-compatible with OpenAI’s Chat Completions API for the parts both providers share (message shape, function-tool shape, tool-call/response shape, token usage shape), so message conversion, tool conversion, and response/usage parsing are all reused verbatim from [agent_framework_openai::convert] — the same approach agent-framework-azure takes for Azure OpenAI. Request-option handling is not fully shared, because Mistral’s supported option set differs from OpenAI’s in real ways (see apply_options), so that part is implemented here instead of reused.

Functions§

apply_options
Apply the scalar ChatOptions fields Mistral’s Chat Completions API actually supports onto a request body map.
build_request
Build a full Mistral POST /v1/chat/completions request body.
classify_mistral_error
Classify a non-success Mistral Chat Completions API HTTP response into a granular Error.
parse_response
Parse a full (non-streaming) Mistral chat-completion response.