1. Installation

Install the traceAI package to access the observability framework.

pip install traceAI-mistralai

2. Set Environment Variables

Set up your environment variables to authenticate with both FutureAGI and MistralAI .

import os

os.environ["FI_API_KEY"] = "your-futureagi-api-key"
os.environ["FI_SECRET_KEY"] = "your-futureagi-secret-key"
os.environ["MISTRAL_API_KEY"] = "your-mistral-api-key"

3. Initialize Trace Provider

Set up the trace provider to create a new project in FutureAGI, establish telemetry data pipelines .

from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType

trace_provider = register(
    project_type=ProjectType.OBSERVE,
    project_name="mistralai_project",
)

4. Instrument your Project

Instrument your Project with MistralAI Instrumentor. This step ensures that all interactions with the MistralAI are tracked and monitored.

from traceai_mistralai import MistralAIInstrumentor

MistralAIInstrumentor().instrument(tracer_provider=trace_provider)

5. Create Mistral AI Components

Set up your Mistral AI client and use your application as you normally would. Our Instrumentor will automatically trace and send the telemetry data to our platform.

from mistralai import Mistral

client = Mistral(api_key=os.environ["MISTRAL_API_KEY"])

response = client.agents.complete(
    agent_id="agent_id",
    messages=[
        {"role": "user", "content": "plan a vacation for me in Tbilisi"},
    ],
)

print(response)

Was this page helpful?