Mistral

Auto-instrumented in Python. In Node, wrap calls with the llm helper.

In Python, install the instrumentor and Mistral calls inside wrap your agent auto-capture. There's no upstream Node instrumentor, so in Node wrap calls with the llm helper. The provider field is mistralai.

What's captured (Python)

CallSpan kindAuto-extracted
client.chat.completellmmodel, tokens, messages, completion
client.chat.streamllmsame, accumulated
client.embeddings.createllmmodel, input tokens

Install

pip install mistralai opentelemetry-instrumentation-mistralai

Minimal example — Python (auto)

import os, trodo
from mistralai import Mistral

trodo.init(site_id=os.environ['TRODO_SITE_ID'])
client = Mistral(api_key=os.environ['MISTRAL_API_KEY'])

with trodo.wrap_agent('mistral-bot') as run:
    r = client.chat.complete(
        model='mistral-large-latest',
        messages=[{'role': 'user', 'content': 'Summarise HNSW.'}],
    )
    run.set_output(r.choices[0].message.content)

Node — wrap with the llm helper

The default token extractor handles Mistral's OpenAI-shaped usage.prompt_tokens / completion_tokens.

import trodo from 'trodo-node';
import { Mistral } from '@mistralai/mistralai';

trodo.init({ siteId: process.env.TRODO_SITE_ID });
const client = new Mistral({ apiKey: process.env.MISTRAL_API_KEY });

const chat = trodo.llm(
  'mistral.chat',
  async (messages) => client.chat.complete({ model: 'mistral-large-latest', messages }),
  { model: 'mistral-large-latest', provider: 'mistralai' },
);

await trodo.wrapAgent('mistral-bot', async (run) => {
  const r = await chat([{ role: 'user', content: 'Summarise HNSW.' }]);
  run.setOutput(r.choices[0].message.content);
});

On this page