@@ -77,6 +77,28 @@ const response = await client.chat.completions.create({
7777
7878</PlatformSection >
7979
80+ <PlatformSection supported = { [" javascript.nextjs" ]} >
81+ For Next.js applications, you need to manually instrument the OpenAI client using the ` instrumentOpenAiClient ` helper:
82+
83+ ``` javascript
84+ import * as Sentry from " @sentry/nextjs" ;
85+ import OpenAI from " openai" ;
86+
87+ const openai = new OpenAI ();
88+ const client = Sentry .instrumentOpenAiClient (openai, {
89+ recordInputs: true ,
90+ recordOutputs: true ,
91+ });
92+
93+ // Use the wrapped client instead of the original openai instance
94+ const response = await client .chat .completions .create ({
95+ model: " gpt-4o" ,
96+ messages: [{ role: " user" , content: " Hello!" }],
97+ });
98+ ```
99+
100+ </PlatformSection >
101+
80102<PlatformSection supported = { [" javascript" ]} >
81103For browser applications, you need to manually instrument the OpenAI client using the ` instrumentOpenAiClient ` helper:
82104
@@ -138,31 +160,6 @@ By default this integration adds tracing support to OpenAI API method calls incl
138160
139161The integration will automatically detect streaming vs non-streaming requests and handle them appropriately.
140162
141- <PlatformSection supported = { [' javascript.nextjs' ]} >
142-
143- ## Node.js and Edge Runtime
144-
145- For Next.js applications, you need to manually instrument the OpenAI client:
146-
147- ``` javascript
148- import * as Sentry from " @sentry/nextjs" ;
149- import OpenAI from " openai" ;
150-
151- const openai = new OpenAI ();
152- const client = Sentry .instrumentOpenAiClient (openai, {
153- recordInputs: true ,
154- recordOutputs: true ,
155- });
156-
157- // Use the wrapped client instead of the original openai instance
158- const response = await client .chat .completions .create ({
159- model: " gpt-4o" ,
160- messages: [{ role: " user" , content: " Hello!" }],
161- });
162- ```
163-
164- </PlatformSection >
165-
166163## Supported Versions
167164
168165- ` openai ` : ` >=4.0.0 <6 `
0 commit comments