OpenInference Mistral AI Instrumentation
Python autoinstrumentation library for MistralAI's Python SDK.
The traces emitted by this instrumentation are fully OpenTelemetry compatible and can be sent to an OpenTelemetry collector for viewing, such as Arize Phoenix or Arize AX.
Compatibility
openinference-instrumentation-mistralai |
mistralai |
|---|---|
<2.0.0 |
>=1.0.2, <2.0.0 |
>=2.0.0 |
>=2.0.0 |
Installation
pip install openinference-instrumentation-mistralai
Quickstart
In this example we will instrument a small program that uses the MistralAI chat completions API and observe the traces via arize-phoenix.
Install packages.
pip install openinference-instrumentation-mistralai mistralai arize-phoenix opentelemetry-sdk opentelemetry-exporter-otlp
Start the phoenix server so that it is ready to collect traces. The Phoenix server runs entirely on your machine and does not send data over the internet.
python -m phoenix.server.main serve
In a python file, setup the MistralAIInstrumentor and configure the tracer to send traces to Phoenix.
from mistralai.client import Mistral
from mistralai.models.chat_completion import ChatMessage
from openinference.instrumentation.mistralai import MistralAIInstrumentor
from opentelemetry import trace as trace_api
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk import trace as trace_sdk
from opentelemetry.sdk.trace.export import ConsoleSpanExporter, SimpleSpanProcessor
endpoint = "http://127.0.0.1:6006/v1/traces"
tracer_provider = trace_sdk.TracerProvider()
tracer_provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter(endpoint)))
# Optionally, you can also print the spans to the console.
tracer_provider.add_span_processor(SimpleSpanProcessor(ConsoleSpanExporter()))
trace_api.set_tracer_provider(tracer_provider)
MistralAIInstrumentor().instrument()
if __name__ == "__main__":
client = Mistral()
response = client.chat(
model="mistral-large-latest",
messages=[
ChatMessage(
content="Who won the World Cup in 2018?",
role="user",
)
],
)
print(response.choices[0].message.content)
Since we are using MistralAI, we must set the MISTRAL_API_KEY environment variable to authenticate with the MistralAI API.
export MISTRAL_API_KEY=[your_key_here]
Now simply run the python file and observe the traces in Phoenix.
python your_file.py
More Info
Metadata
Release files for openinference-instrumentation-mistralai 2.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| openinference_instrumentation_mistralai-2.1.7.tar.gz | 23.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| openinference_instrumentation_mistralai-2.1.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 44.2 kB
Release files / openinference_instrumentation_mistralai-2.1.7.tar.gz
| Download URL | openinference_instrumentation_mistralai-2.1.7.tar.gz |
|---|---|
| Size | 23.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
85c149faf4af02a1d67ffe635cba05a8352f4afe7a9c10d3ab3c7946197b84ba
|
|
BLAKE2b-256 checksum How to use checksums |
5598785e11105576a86ef2522b4b5991f92db734cc3824d9844596385dc6901c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 1, 2026.
Transparency logRelease files / openinference_instrumentation_mistralai-2.1.7-py3-none-any.whl
| Download URL | openinference_instrumentation_mistralai-2.1.7-py3-none-any.whl |
|---|---|
| Size | 21.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f595b2aef3a24dfa6b332d5ed41ab9b0168ec7881b19313cadf75cd6532c8fba
|
|
BLAKE2b-256 checksum How to use checksums |
e64b8f728e28cd829bedbdd0a4131994d90b7e1f04675d05b1f5ffc3a55b7485
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 1, 2026.
Transparency log