In this article
Keep provider and estimated token counts explicitly labeled, and test provider failure before using native Mistral counts as a context-admission decision.
The November 15 LiteLLM v1.111.0-dev.4 prerelease adds upstream Mistral token counting. When the provider endpoint is requested, its failures are surfaced instead of silently returning a local estimate. Applications using counts for context admission should preserve count provenance and availability, because an exact-looking number without its source can hide a fallback the caller never intended.
Count the request after its real transformation
Use matched synthetic requests through each protocol the application sends to the Mistral deployment. Capture the transformed input delivered to the counter and inference path. An upstream count is useful only for the same effective content. Tool definitions, restored history and files can alter that content even when the visible user text is unchanged. Compare the resolved model and credentials as well as the returned number.
Errors should not look like accurate counts
Make the synthetic provider return authentication failure and a timeout in separate cases. Assert the caller receives the intended error when upstream counting is required. If the application chooses to permit a local estimate, label that as its own explicit policy and record the source change. The release intentionally changes this failure contract, so a broad catch-all that substitutes zero would defeat the purpose of using a provider count.
Restored history contributes to admission
Include a follow-up referencing prior response state and a supported file-bearing request. Compare with a fresh standalone input whose history is empty. The implementation describes counting restored history and replayed reasoning, so testing only the newest prompt would miss an important boundary. Use harmless known content and immutable fixture identities to keep a changing remote conversation from making the expected count ambiguous.
Input counts do not reserve future output
After validating provenance, combine the input count with the application’s explicit output allowance and model limits. A counted request is not automatically affordable or guaranteed to complete. Record count latency and failure rate separately from inference latency. The prerelease adds an integration and clearer error semantics, not a universal token-precision promise for every model or a claim that counting eliminates the need for bounded generation and budget checks.
Sources
Related reading
Earn rental income from GPUs
Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.