Mistral AI for React Router Framework
Adds instrumentation for the Mistral AI SDK. (default)
Requires SDK version 11.0.0 or higher.
Import name: Sentry.mistralAIIntegration
This integration is enabled by default when tracing is enabled. If you'd like to modify your default integrations, read this.
The mistralAIIntegration adds instrumentation for the @mistralai/mistralai SDK to capture agent tracing gen_ai spans, recording model, token usage, latency, and (when enabled) inputs and outputs.
Sentry.init({
dsn: "___PUBLIC_DSN___",
// Tracing must be enabled for agent tracing to work.
// `mistralAIIntegration` is then on by default; add it to `integrations` only to change its options.
tracesSampleRate: 1.0,
});
Sentry.init({
dsn: "___PUBLIC_DSN___",
// Tracing must be enabled for agent tracing to work.
// `mistralAIIntegration` is then on by default; add it to `integrations` only to change its options.
tracesSampleRate: 1.0,
});
To group multi-turn chats in Conversations and show who started them, set a conversation ID and user in every request that makes AI calls. See Tracking Conversations.
By default, tracing support is added to the following Mistral AI SDK calls:
chat.complete()/chat.parse()- Chat completion requestschat.stream()/chat.parseStream()- Streaming chat completionsembeddings.create()- Embedding requestsagents.complete()- Agent completion requestsagents.stream()- Streaming agent completions
Streaming and non-streaming requests are automatically detected and handled appropriately.
@mistralai/mistralai:>=2.0.0 <3
Type: boolean (optional)
Records inputs to Mistral AI SDK calls (such as prompts and messages).
Defaults to true if dataCollection.genAI.inputs is true, which is the default.
Type: boolean (optional)
Records outputs from Mistral AI SDK calls (such as generated text and responses).
Defaults to true if dataCollection.genAI.outputs is true, which is the default.
Sentry.init({
dsn: "___PUBLIC_DSN___",
tracesSampleRate: 1.0,
integrations: [
Sentry.mistralAIIntegration({
recordInputs: false,
recordOutputs: false,
}),
],
});
Sentry.init({
dsn: "___PUBLIC_DSN___",
tracesSampleRate: 1.0,
integrations: [
Sentry.mistralAIIntegration({
recordInputs: false,
recordOutputs: false,
}),
],
});
Import name: Sentry.instrumentMistralAiClient
If your application does not use automatic instrumentation, wrap your Mistral client after setting up Sentry. Use the returned client for all Mistral calls.
import * as Sentry from "___SDK_PACKAGE___";
import * as Sentry from "___SDK_PACKAGE___";
import { Mistral } from "@mistralai/mistralai";
const mistral = new Mistral({ apiKey: "your-mistral-api-key" });
const client = Sentry.instrumentMistralAiClient(mistral, {
recordInputs: false,
recordOutputs: false,
});
const response = await client.chat.complete({
model: "mistral-small-latest",
messages: [{ role: "user", content: "Hello!" }],
});
import { Mistral } from "@mistralai/mistralai";
const mistral = new Mistral({ apiKey: "your-mistral-api-key" });
const client = Sentry.instrumentMistralAiClient(mistral, {
recordInputs: false,
recordOutputs: false,
});
const response = await client.chat.complete({
model: "mistral-small-latest",
messages: [{ role: "user", content: "Hello!" }],
});
Use one instrumentation approach for each client. If automatic instrumentation is already active, you don't need to wrap the client.
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").