Mistral publishes open-weight AI models that can be used for a variety of tasks. To develop with Mistral, visit their developer docs here.

Steps to Integrate Mistral with AgentOps

1

Install the AgentOps SDK

pip install agentops
2

Install the Mistral SDK

pip install mistralai
3

Initialize AgentOps and develop with Mistral

Make sure to call agentops.init before calling any openai, cohere, crew, etc models.

from mistralai import Mistral
import agentops

agentops.init(<INSERT YOUR API KEY HERE>)
client = Mistral(api_key="your_api_key")

# Your code here...

agentops.end_session('Success')

Set your API key as an .env variable for easy access.

AGENTOPS_API_KEY=<YOUR API KEY>
MISTRAL_API_KEY=<YOUR MISTRAL API KEY>
4

Run your Agent

Execute your program and visit app.agentops.ai/drilldown to observe your Agent! 🕵️

After your run, AgentOps prints a clickable url to console linking directly to your session in the Dashboard

Clickable link to session

Full Examples

A notebook demonstrating how to use AgentOps with Mistral can be found here.

from mistralai import Mistral
import agentops

agentops.init(<INSERT YOUR API KEY HERE>)
client = Mistral(api_key="your_api_key")

response = client.chat.complete(
    model="mistral-small-latest",
    messages=[
        {
            "role": "user",
            "content": "Explain the history of the French Revolution."
        }
    ],
)

print(response.choices[0].message.content)
agentops.end_session('Success')

Streaming Examples

from mistralai import Mistral
import agentops

agentops.init(<INSERT YOUR API KEY HERE>)
client = Mistral(api_key="your_api_key")

complete_response = ""

response = client.chat.stream(
    model="mistral-small-latest",
    messages=[
        {
            "role": "user",
            "content": "Who was Joan of Arc?"
        }
    ],
)

for chunk in response:
    if chunk.data.choices[0].finish_reason == "stop":
        print(complete_response)
    else:
        complete_response += chunk.data.choices[0].delta.content

agentops.end_session('Success')