|
| 1 | +--- |
| 2 | +title: Set Up |
| 3 | +sidebar_order: 0 |
| 4 | +description: "Learn how to set up Sentry AI Agent Monitoring" |
| 5 | +--- |
| 6 | + |
| 7 | +Sentry AI Agent Monitoring helps you track and debug AI agent applications using our supported SDKs and integrations. Monitor your complete agent workflows from user interaction to final response, including tool calls, model interactions, and custom logic. |
| 8 | + |
| 9 | +To start sending AI agent data to Sentry, make sure you've created a Sentry project for your AI-enabled repository and follow one of the guides below: |
| 10 | + |
| 11 | +## Supported SDKs |
| 12 | + |
| 13 | +### JavaScript - Vercel AI SDK |
| 14 | + |
| 15 | +The Sentry JavaScript SDK supports AI agent monitoring through the Vercel AI integration, which works with Node.js and Bun runtimes. This integration automatically captures spans for your AI agent workflows using the AI SDK's built-in telemetry. |
| 16 | + |
| 17 | +#### Supported Platforms |
| 18 | + |
| 19 | +- <LinkWithPlatformIcon |
| 20 | + platform="javascript.node" |
| 21 | + label="Node.js" |
| 22 | + url="/platforms/javascript/guides/node/configuration/integrations/vercelai/" |
| 23 | + /> |
| 24 | +- <LinkWithPlatformIcon |
| 25 | + platform="javascript.nextjs" |
| 26 | + label="Next.js" |
| 27 | + url="/platforms/javascript/guides/nextjs/configuration/integrations/vercelai/" |
| 28 | + /> |
| 29 | +- <LinkWithPlatformIcon |
| 30 | + platform="javascript.sveltekit" |
| 31 | + label="SvelteKit" |
| 32 | + url="/platforms/javascript/guides/sveltekit/configuration/integrations/vercelai/" |
| 33 | + /> |
| 34 | +- <LinkWithPlatformIcon |
| 35 | + platform="javascript.nuxt" |
| 36 | + label="Nuxt" |
| 37 | + url="/platforms/javascript/guides/nuxt/configuration/integrations/vercelai/" |
| 38 | + /> |
| 39 | +- <LinkWithPlatformIcon |
| 40 | + platform="javascript.astro" |
| 41 | + label="Astro" |
| 42 | + url="/platforms/javascript/guides/astro/configuration/integrations/vercelai/" |
| 43 | + /> |
| 44 | +- <LinkWithPlatformIcon |
| 45 | + platform="javascript.remix" |
| 46 | + label="Remix" |
| 47 | + url="/platforms/javascript/guides/remix/configuration/integrations/vercelai/" |
| 48 | + /> |
| 49 | +- <LinkWithPlatformIcon |
| 50 | + platform="javascript.solidstart" |
| 51 | + label="SolidStart" |
| 52 | + url="/platforms/javascript/guides/solidstart/configuration/integrations/vercelai/" |
| 53 | + /> |
| 54 | +- <LinkWithPlatformIcon |
| 55 | + platform="javascript.express" |
| 56 | + label="Express" |
| 57 | + url="/platforms/javascript/guides/express/configuration/integrations/vercelai/" |
| 58 | + /> |
| 59 | +- <LinkWithPlatformIcon |
| 60 | + platform="javascript.fastify" |
| 61 | + label="Fastify" |
| 62 | + url="/platforms/javascript/guides/fastify/configuration/integrations/vercelai/" |
| 63 | + /> |
| 64 | +- <LinkWithPlatformIcon |
| 65 | + platform="javascript.nestjs" |
| 66 | + label="Nest.js" |
| 67 | + url="/platforms/javascript/guides/nestjs/configuration/integrations/vercelai/" |
| 68 | + /> |
| 69 | +- <LinkWithPlatformIcon |
| 70 | + platform="javascript.hapi" |
| 71 | + label="Hapi" |
| 72 | + url="/platforms/javascript/guides/hapi/configuration/integrations/vercelai/" |
| 73 | + /> |
| 74 | +- <LinkWithPlatformIcon |
| 75 | + platform="javascript.koa" |
| 76 | + label="Koa" |
| 77 | + url="/platforms/javascript/guides/koa/configuration/integrations/vercelai/" |
| 78 | + /> |
| 79 | +- <LinkWithPlatformIcon |
| 80 | + platform="javascript.connect" |
| 81 | + label="Connect" |
| 82 | + url="/platforms/javascript/guides/connect/configuration/integrations/vercelai/" |
| 83 | + /> |
| 84 | +- <LinkWithPlatformIcon |
| 85 | + platform="javascript.hono" |
| 86 | + label="Hono" |
| 87 | + url="/platforms/javascript/guides/hono/configuration/integrations/vercelai/" |
| 88 | + /> |
| 89 | +- <LinkWithPlatformIcon |
| 90 | + platform="javascript.bun" |
| 91 | + label="Bun" |
| 92 | + url="/platforms/javascript/guides/bun/configuration/integrations/vercelai/" |
| 93 | + /> |
| 94 | +- <LinkWithPlatformIcon |
| 95 | + platform="javascript.aws-lambda" |
| 96 | + label="AWS Lambda" |
| 97 | + url="/platforms/javascript/guides/aws-lambda/configuration/integrations/vercelai/" |
| 98 | + /> |
| 99 | +- <LinkWithPlatformIcon |
| 100 | + platform="javascript.azure-functions" |
| 101 | + label="Azure Functions" |
| 102 | + url="/platforms/javascript/guides/azure-functions/configuration/integrations/vercelai/" |
| 103 | + /> |
| 104 | +- <LinkWithPlatformIcon |
| 105 | + platform="javascript.gcp-functions" |
| 106 | + label="Google Cloud Functions" |
| 107 | + url="/platforms/javascript/guides/gcp-functions/configuration/integrations/vercelai/" |
| 108 | + /> |
| 109 | +- <LinkWithPlatformIcon |
| 110 | + platform="javascript.electron" |
| 111 | + label="Electron" |
| 112 | + url="/platforms/javascript/guides/electron/configuration/integrations/vercelai/" |
| 113 | + /> |
| 114 | + |
| 115 | +#### Quick Start with Vercel AI SDK |
| 116 | + |
| 117 | +```javascript |
| 118 | +import { Sentry } from "@sentry/node"; |
| 119 | +import { generateText } from "ai"; |
| 120 | +import { openai } from "@ai-sdk/openai"; |
| 121 | + |
| 122 | +Sentry.init({ |
| 123 | + tracesSampleRate: 1.0, |
| 124 | + integrations: [ |
| 125 | + Sentry.vercelAIIntegration({ |
| 126 | + recordInputs: true, |
| 127 | + recordOutputs: true, |
| 128 | + }), |
| 129 | + ], |
| 130 | +}); |
| 131 | + |
| 132 | +// Your AI agent function |
| 133 | +async function aiAgent(userQuery) { |
| 134 | + const result = await generateText({ |
| 135 | + model: openai("gpt-4o"), |
| 136 | + prompt: userQuery, |
| 137 | + experimental_telemetry: { |
| 138 | + isEnabled: true, |
| 139 | + functionId: "ai-agent-main", |
| 140 | + }, |
| 141 | + }); |
| 142 | + |
| 143 | + return result.text; |
| 144 | +} |
| 145 | +``` |
| 146 | + |
| 147 | +### Python - OpenAI Agents |
| 148 | + |
| 149 | +The Sentry Python SDK supports OpenAI Agents SDK. |
| 150 | + |
| 151 | +#### Quick Start with OpenAI Agents |
| 152 | + |
| 153 | +```python |
| 154 | +import sentry_sdk |
| 155 | +from sentry_sdk.integrations.openai_agents import OpenAIAgentsIntegration |
| 156 | +import agents |
| 157 | +from pydantic import BaseModel |
| 158 | + |
| 159 | +sentry_sdk.init( |
| 160 | + dsn="YOUR_DSN", |
| 161 | + traces_sample_rate=1.0, |
| 162 | + send_default_pii=True, # Include LLM inputs/outputs |
| 163 | + integrations=[ |
| 164 | + OpenAIAgentsIntegration(), |
| 165 | + ], |
| 166 | +) |
| 167 | + |
| 168 | +# Create your AI agent |
| 169 | +my_agent = agents.Agent( |
| 170 | + name="My Agent", |
| 171 | + instructions="You are a helpful assistant.", |
| 172 | + model="gpt-4o-mini", |
| 173 | +) |
| 174 | + |
| 175 | +# Your AI agent function |
| 176 | +result = await agents.Runner.run( |
| 177 | + my_agent, |
| 178 | + input=user_query, |
| 179 | +) |
| 180 | + |
| 181 | +``` |
| 182 | + |
| 183 | +<Alert title="Don't see your platform?"> |
| 184 | + |
| 185 | +We'll be adding AI agent integrations continuously. You can also instrument AI agents manually by following our [manual instrumentation guide](/platforms/python/tracing/instrumentation/custom-instrumentation/ai-agents-module). |
| 186 | + |
| 187 | +</Alert> |
0 commit comments