-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat: Document OpenAI integration #14511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
107 changes: 107 additions & 0 deletions
107
docs/platforms/javascript/common/configuration/integrations/openai.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| --- | ||
| title: OpenAI | ||
| description: "Adds instrumentation for OpenAI API." | ||
| supported: | ||
| - javascript.node | ||
| - javascript.aws-lambda | ||
| - javascript.azure-functions | ||
| - javascript.connect | ||
| - javascript.express | ||
| - javascript.fastify | ||
| - javascript.gcp-functions | ||
| - javascript.hapi | ||
| - javascript.hono | ||
| - javascript.koa | ||
| - javascript.nestjs | ||
| - javascript.electron | ||
| - javascript.nextjs | ||
| - javascript.nuxt | ||
| - javascript.solidstart | ||
| - javascript.sveltekit | ||
| - javascript.react-router | ||
| - javascript.remix | ||
| - javascript.astro | ||
| - javascript.bun | ||
| - javascript.tanstackstart-react | ||
| --- | ||
|
|
||
| <Alert> | ||
|
|
||
| This integration only works in the Node.js runtime. Requires SDK version `9.44.0` or higher. | ||
|
|
||
| </Alert> | ||
|
|
||
| _Import name: `Sentry.openAIIntegration`_ | ||
|
|
||
| The `openAIIntegration` adds instrumentation for the `openai` API to capture spans by automatically wrapping OpenAI client calls and recording LLM interactions with configurable input/output recording. | ||
|
|
||
| It is enabled by default and will automatically capture spans for all OpenAI API method calls. You can opt-in to capture inputs and outputs by setting `recordInputs` and `recordOutputs` in the integration config: | ||
|
|
||
| ```javascript | ||
| Sentry.init({ | ||
| dsn: "____PUBLIC_DSN____", | ||
| tracesSampleRate: 1.0, | ||
| integrations: [ | ||
| Sentry.openAIIntegration({ | ||
| recordInputs: true, | ||
| recordOutputs: true, | ||
| }), | ||
| ], | ||
| }); | ||
| ``` | ||
|
|
||
| <PlatformSection supported={['javascript.nextjs']}> | ||
|
|
||
| This integration only works in the Node.js runtime, not in the Edge runtime. For Next.js applications using the Edge runtime, this integration will not be available. | ||
|
|
||
| </PlatformSection> | ||
|
|
||
| <PlatformSection> | ||
| ## Options | ||
|
|
||
| ### `recordInputs` | ||
|
|
||
| Requires SDK version `9.44.0` or higher. | ||
|
||
|
|
||
| _Type: `boolean`_ | ||
|
|
||
| Records inputs to OpenAI API method calls (such as prompts and messages). | ||
|
|
||
| Defaults to `true` if `sendDefaultPii` is `true`. | ||
|
|
||
| ```javascript | ||
| Sentry.init({ | ||
| integrations: [Sentry.openAIIntegration({ recordInputs: true })], | ||
| }); | ||
| ``` | ||
|
|
||
| ### `recordOutputs` | ||
|
|
||
| Requires SDK version `9.44.0` or higher. | ||
|
|
||
| _Type: `boolean`_ | ||
|
|
||
| Records outputs from OpenAI API method calls (such as generated text and responses). | ||
|
|
||
| Defaults to `true` if `sendDefaultPii` is `true`. | ||
|
|
||
| ```javascript | ||
| Sentry.init({ | ||
| integrations: [Sentry.openAIIntegration({ recordOutputs: true })], | ||
| }); | ||
| ``` | ||
|
|
||
| </PlatformSection> | ||
|
|
||
| ## Configuration | ||
|
|
||
| By default this integration adds tracing support to OpenAI API method calls including: | ||
|
|
||
| - `chat.completions.create()` - Chat completion requests | ||
| - `responses.create()` - Response API requests | ||
|
|
||
| The integration will automatically detect streaming vs non-streaming requests and handle them appropriately. | ||
|
|
||
| ## Supported Versions | ||
|
|
||
| - `openai`: `>=4.0.0 <6` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.