Mistral client in place and instruments:
client.chat.complete(...)client.chat.stream(...)
Install
Wrap and call
Streaming
Usage is captured from the final chunk of the stream.The TypeScript wrapper preserves
chat.stream’s async-function shape, so instanceof Promise and .then(...) behave exactly as on the unwrapped client.Per-call override
extra_lago / lago before forwarding.
What gets captured
Not exposed by Mistral:
cache_write and its TTL splits, reasoning (folded into completion_tokens), image_input, audio_input, audio_output.
cache_read only appears on a cache hit. The correct source field is usage.prompt_tokens_details.cached_tokens. Mistral has no prompt_cache_hit_tokens field, contrary to what some third-party integrations assume.cache_read is part of prompt_tokens, not additive to it — Mistral’s own documented example reports prompt_tokens: 1013 with cached_tokens: 1008, and total_tokens equal to prompt plus completion. Bill llm_input_tokens as the total and use llm_cached_input_tokens for a discounted rate tier; Bill in tokens shows the setup.
What is and isn’t instrumented
wrap() patches four methods on client.chat: complete, stream, complete_async, and stream_async.
Structured outputs are covered. chat.parse calls complete internally, so it routes through the instrumented method and bills normally — as do parse_async, parse_stream, and parse_stream_async.
Other billable surfaces on the client are unmetered: fim (fill-in-the-middle), embeddings, ocr, agents, classifiers, audio, batch, and beta. If you use those, build a CanonicalUsage yourself and pass it to sdk.emit().
Mistral models through Bedrock
Calling Mistral models on AWS Bedrock is a different code path with different coverage. Notably, the legacy models (Mistral 7B, Mixtral 8x7B, Mistral Large 24.02) report no usage at all throughInvokeModel. See the Bedrock page.
Pricing
In price mode, native Mistral clients are priced from OpenRouter’s public model list, per token, refreshed hourly on the background thread.Next steps
Configuration reference
Every config knob, in both SDKs.
Per-token pricing template
A complete plan built on Mistral token metrics.