You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Automatic instrumentation of the OpenAI SDK may not work as expected with certain Next.js configurations (especially with Turbopack and in Next.js 16). In these cases, manual instrumentation via `instrumentOpenAiClient` is recommended.
146
-
147
-
For projects using Next.js 15 or earlier with Webpack, the following configuration can be applied in your `next.config.js` to ensure proper instrumentation:
148
-
149
-
```javascript
150
-
module.exports= {
151
-
webpack(config, { isServer }) {
152
-
if (isServer) {
153
-
// Force 'openai' to be required dynamically (not bundled)
154
-
// This allows Sentry to instrument the OpenAI SDK at runtime
155
-
config.externals=config.externals|| [];
156
-
config.externals.push("openai");
157
-
}
158
-
return config;
159
-
},
160
-
};
161
-
```
162
-
163
-
This ensures the package is externalized at runtime.
164
-
165
-
<Alert>
166
-
167
-
Note that this cannot be achieved using `serverExternalPackages: ['openai']`.
168
-
169
-
</Alert>
170
-
171
-
## Edge Runtime
172
-
173
-
For Next.js applications using the Edge runtime, you need to manually instrument the OpenAI client:
145
+
For Next.js applications, you need to manually instrument the OpenAI client:
0 commit comments