Mistral AI tracing
Trace Mistral chat completions, embeddings, and conversations in Future AGI, including model names, messages, token usage, tool calls, and errors.
Install
Use Python 3.10–3.13 and the current Mistral SDK:
pip install traceAI-mistralai 'mistralai>=3.6,<4'
Set FI_API_KEY, FI_SECRET_KEY, and MISTRAL_API_KEY in your environment. Use your own Mistral API key for model requests.
Trace a completion
import os
from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType
from mistralai.client import Mistral
from traceai_mistralai import MistralAIInstrumentor
provider = register(
project_type=ProjectType.OBSERVE,
project_name="mistral-app",
)
MistralAIInstrumentor().instrument(tracer_provider=provider)
try:
with Mistral(api_key=os.environ["MISTRAL_API_KEY"]) as client:
response = client.chat.complete(
model="mistral-small-latest",
messages=[{"role": "user", "content": "Suggest three names for a neighborhood bookstore."}],
)
print(response.choices[0].message.content)
finally:
provider.shutdown()
Open Observe in Future AGI and select mistral-app. The completion appears as an LLM span with the model and returned usage.
The integration routes the SDK's native OpenTelemetry spans through your provider. Do not add another Mistral instrumentor or configure a second Mistral exporter. Clients created before instrumentation are supported too. Configure tracing once at startup; finish active requests and close streams before uninstrumenting.
Stream a response
Use the stream's context manager so the connection and span close even when you stop reading early:
with client.chat.stream(
model="mistral-small-latest",
messages=[{"role": "user", "content": "Describe a cozy bookstore."}],
) as stream:
for event in stream:
print(event.data.choices[0].delta.content or "", end="")
For async requests, use await client.chat.complete_async(...) or async with await client.chat.stream_async(...). Keep the client open until the stream is closed. Token usage is available when the service returns it; an early-closed stream may not receive usage.
Control captured content
Messages and tool arguments can contain sensitive data. To keep model names, token counts, timing, and error status without recording input or output content, replace the instrumentor call above with:
from fi_instrumentation import TraceConfig
MistralAIInstrumentor().instrument(
tracer_provider=provider,
config=TraceConfig(hide_inputs=True, hide_outputs=True),
)
This also hides error details by default. Embedding vectors are not captured.
Supported APIs
- SDK 3.6–3.x: native sync/async chat and agent completions, streaming, embeddings, and
beta.conversations.start,append, andrestart, including their async and streaming variants. Conversation streaming errors and final usage are captured on the native span. - SDK 1.1–1.x: the existing
MistralAIInstrumentorentry point continues to support chat and agent completions and streams, plus embeddings. Keepfrom mistralai import Mistralfor this SDK line. Conversation tracing requires SDK 3.6 or later. - SDK 1.0, 2.x, and 3.0–3.5 are outside the supported range. Pin one of the ranges above rather than overriding pip's dependency check.
Troubleshooting
cannot import name Mistral: usefrom mistralai.client import Mistralwith SDK 3.6 or later. The top-level import belongs to SDK 1.x.- Missing streaming spans: fully consume or explicitly close the stream before flushing or shutting down your tracer provider.
- Duplicate spans: remove other Mistral SDK instrumentors. This integration adapts native telemetry rather than adding a second completion span.
Metadata
Release files for traceAI-mistralai 0.1.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| traceai_mistralai-0.1.10.tar.gz | 21.5 kB | With provenance | Details for traceai_mistralai-0.1.10.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| traceai_mistralai-0.1.10-py3-none-any.whl | Python 3 | none | any | Details for traceai_mistralai-0.1.10-py3-none-any.whl |
Total release size: 48.2 kB
Release files / traceai_mistralai-0.1.10.tar.gz
| Download URL | traceai_mistralai-0.1.10.tar.gz |
|---|---|
| Size | 21.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7af8717f3384b481487d8215d263ac29bbec258f849daaffc3666fcbbaea2c0e
|
|
BLAKE2b-256 checksum How to use checksums |
9454591cc04daae35c5f835b3e918ab2e16efae0d34c216347b2b04bb034f5a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logRelease files / traceai_mistralai-0.1.10-py3-none-any.whl
| Download URL | traceai_mistralai-0.1.10-py3-none-any.whl |
|---|---|
| Size | 26.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
19af8855b64e74c6e854c3e2b0e2d8536311618e5243aaa63c034e2e98a230fe
|
|
BLAKE2b-256 checksum How to use checksums |
de0e93663f51b8b13285cf4faa09795a48139d49574fc2942d999ce70f5f1a3d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logSecurity for traceAI-mistralai 0.1.10
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for traceai_mistralai-0.1.10.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.