Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,65 @@ Sentry.init({
});
```

<PlatformSection supported={["javascript.deno"]}>

On Deno, preload Sentry's import hook so the Mistral SDK can be instrumented:

```bash
deno run --allow-net --allow-env --allow-read --allow-sys --allow-write --preload=npm:@sentry/deno/import app.ts
```

</PlatformSection>

<PlatformSection supported={["javascript.bun", "javascript.elysia"]}>

<PlatformSection supported={["javascript.elysia"]}>

With the Node.js adapter, no build step is needed. The integration is enabled by default when tracing is enabled.

On Bun, add `sentryBunPlugin()` to your build so the plugin can instrument the bundled Mistral SDK:

</PlatformSection>

<PlatformSection notSupported={["javascript.elysia"]}>

On Bun, add `sentryBunPlugin()` to your build so the plugin can instrument the bundled Mistral SDK:

</PlatformSection>

```typescript {filename:build.ts}
import { sentryBunPlugin } from "@sentry/bun/plugin";

await Bun.build({
entrypoints: ["./src/index.ts"],
outdir: "./dist",
target: "bun",
plugins: [sentryBunPlugin()],
});
```

The Mistral SDK must be part of the bundle. The plugin only runs during a build, so for unbundled applications started with `bun run`, use [Manual Instrumentation](#manual-instrumentation).

</PlatformSection>
Comment thread
sentry[bot] marked this conversation as resolved.

<PlatformSection supported={["javascript.cloudflare"]}>

On Cloudflare, add `sentryCloudflareVitePlugin()` alongside Cloudflare's Vite plugin so the bundled Mistral SDK is instrumented:

```typescript {filename:vite.config.mts}
import { cloudflare } from "@cloudflare/vite-plugin";
import { sentryCloudflareVitePlugin } from "@sentry/cloudflare/vite";
import { defineConfig } from "vite";

export default defineConfig({
plugins: [cloudflare(), sentryCloudflareVitePlugin()],
});
```

Build-time instrumentation is enabled by default, and the plugin registers the integration in both `vite dev` and `vite build`. Keep the `nodejs_compat` flag enabled in your Wrangler configuration, and see the <PlatformLink to="/install/vite-plugin/">Vite plugin</PlatformLink> page for the full setup. Without the plugin, or with `buildTimeInstrumentation: false`, use [Manual Instrumentation](#manual-instrumentation).

</PlatformSection>

## Supported Operations

By default, tracing support is added to the following Mistral AI SDK calls:
Expand Down Expand Up @@ -75,3 +134,44 @@ Sentry.init({
],
});
```

<PlatformSection notSupported={["javascript.deno", "javascript.solidstart"]}>

## Manual Instrumentation

_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.

<PlatformSection supported={["javascript.hono"]}>

Import Sentry from the entry point for your runtime: `@sentry/hono/node`, `@sentry/hono/bun`, or `@sentry/hono/cloudflare`.

</PlatformSection>

<PlatformSection notSupported={["javascript.hono"]}>

```javascript
import * as Sentry from "___SDK_PACKAGE___";
```

</PlatformSection>

```javascript
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.

</PlatformSection>
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@
| [`prismaIntegration`](./prisma) | | | ✓ | | |
| [`honoIntegration`](./hono) | ✓ | ✓ | | | |

[Mistral AI](./mistral) is automatically instrumented when built with the Sentry Cloudflare Vite plugin. Without the plugin, use `instrumentMistralAiClient`.

The [`prismaIntegration`](./prisma) is only available through the [`@sentry/cloudflare/nodejs_compat`](../../features/nodejs-compat) entrypoint.
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@
| [`instrumentPostgresJsSql`](./postgresjs) | | | ✓ | | |
| [`trpcMiddleware`](./trpc) | | ✓ | ✓ | | ✓ |
| [`zodErrorsIntegration`](./zodErrors) | | | | ✓ |
| [`mistralAIIntegration`](./mistral) | ✓ | | ✓ | | |
Loading