Skip to main content

Installation

Setup

Chat API

Span name: "mistral-chat", SpanKind: LLM
What gets traced
  • Input: messages list, captured directly (Mistral already speaks the universal schema)
  • Output: assistant message from choices[0].message
  • Model name (from the response body)
  • Token usage
  • Model parameters: temperature, top_p, max_tokens, random_seed, safe_prompt, response_format, tool_choice, presence_penalty, frequency_penalty, n, stop

Streaming

Both streaming patterns are fully supported with time-to-first-token tracking. The wrapper transparently passes through the SDK’s EventStream / EventStreamAsync context manager, buffers delta.content chunks, and emits a single LLM span containing the full reduced output and the final token usage Mistral reports on the terminal chunk.

Async

The Mistral SDK exposes async via chat.complete_async and chat.stream_async on the same client class — both are instrumented by wrap_mistral. No separate async client class exists.

Token usage mapping

Mistral already uses our canonical names, so the mapping is the identity: