Mistral Wrapper

Wrap your Mistral client to automatically trace every chat.complete() call.

Installation

pip install twosignal[mistral]

Usage

from twosignal import TwoSignal
from twosignal.wrappers.mistral import wrap_mistral
from mistralai import Mistral

ts = TwoSignal()
client = wrap_mistral(Mistral(api_key="your-key"))

response = client.chat.complete(
    model="mistral-large-latest",
    messages=[{"role": "user", "content": "Hello"}],
)

What Gets Captured

FieldDescription
modelModel name (e.g., mistral-large-latest)
inputInput messages array
outputResponse content
usage.prompt_tokensInput token count
usage.completion_tokensOutput token count
costEstimated cost in USD

Async

Both chat.complete and chat.complete_async are wrapped automatically.

Have questions? Join our community!

Connect with other developers and the 2Signal team.

Join Discord