Registry / ai-ml / openinference-instrumentation-mistralai

openinference-instrumentation-mistralai

JSON →
library2.0.4pypypi✓ verified 86d ago

OpenInference instrumentor for Mistral AI Python SDK. Automatically traces Mistral AI calls (chat completions, embeddings, etc.) and exports spans in OpenInference format for observability with Arize AI, Phoenix, and other OpenTelemetry backends. Current version: 2.0.4. Requires Python >=3.9,<3.15. Release cadence: irregular, bundled with OpenInference monorepo.

pip install openinference-instrumentation-mistralai
INSTALL
IMPORT
SIG · OPENINFERENCE-INST
O
openinference-instrumentation-mistralai
ai-mlpythonv2.0.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

MistralAIInstrumentor
✓ from openinference.instrumentation.mistralai import MistralAIInstrumentor
✗ from openinference_instrumentation_mistralai import MistralAIInstrumentor

Basic setup with OTLP exporter. Replace endpoint with your observability backend.

import os from opentelemetry import trace from opentelemetry.sdk.trace import TracerProvider from opentelemetry.sdk.trace.export import SimpleSpanProcessor from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter from openinference_instrumentation_mistralai import MistralAIInstrumentor # Set up OpenTelemetry (example with OTLP HTTP exporter) provider = TracerProvider() provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter(endpoint="https://api.arize.com/v1/traces"))) trace.set_tracer_provider(provider) # Instrument MistralAI MistralAIInstrumentor().instrument() # Now use MistralAI as usual from mistralai import Mistral client = Mistral(api_key=os.environ.get("MISTRAL_API_KEY", "")) response = client.chat.complete(model="mistral-small-latest", messages=[{"role": "user", "content": "Hello"}]) print(response.choices[0].message.content)
Debug
Known issues
breakingImport path changed in v2.0: use underscore pattern (openinference_instrumentation_mistralai) instead of dotted path (openinference.instrumentation.mistralai). Old imports will fail with ModuleNotFoundError.
fix
Update import to: from openinference_instrumentation_mistralai import MistralAIInstrumentor
affects: <2.0
gotchaInstrumentation only works if MistralAI SDK is imported AFTER calling instrument(). If you import mistralai before instrument(), no spans will be captured.
fix
Ensure MistralAIInstrumentor().instrument() is called before any import of mistralai, or at least before creating a client.
affects: all
gotchaVersion 2.x uses OpenTelemetry SDK 1.x. If your application uses a different version of opentelemetry-api/opentelemetry-sdk, you may encounter compatibility issues.
fix
Pin opentelemetry-api >=1.0,<2.0 and opentelemetry-sdk >=1.0,<2.0.
affects: >=2.0
deprecatedSupport for Python 3.8 is deprecated; the package requires Python >=3.9. If you are still on Python 3.8, upgrade or pin to an older version (e.g., 1.x).
fix
Upgrade to Python >=3.9.
affects: >=2.0
Upgrade
Version history
2.0.4latest on PyPI · released May 18, 2026
Audit
Dependencies
openinference-instrumentationrequiredBase instrumentation utilities and OpenInference semantic conventions
mistralairequiredInstrumented SDK; must be installed (usually pip install mistralai)
opentelemetry-apioptionalOpenTelemetry API for span creation
Agent activity
17 hits · last 30 days
node
16
Resources
openinference-instrumentation-mistralai — pip install openinference-instrumentation-mistralai · libregistry