Can not use OpenAI SDK with Sentry Node agent: TypeError: getDefaultAgent is not a function
Problem
Confirm this is a Node library issue and not an underlying OpenAI API issue - [X] This is an issue with the Node library Describe the bug Referenced previously here, closed without resolution: https://github.com/openai/openai-node/issues/903 This is a pretty big issue as it prevents usage of the SDK while using the latest Sentry monitoring package. To Reproduce 1. Install Sentry Node sdk via `npm i @sentry/node --save` 2. Enter the following code; [code block] 3. Try to create a completion somewhere in the process after Sentry has been initialized: [code block] Results in error: [code block] Code snippets (Included) OS All operating systems (macOS, Linux) Node version v20.10.0 Library version v4.56.0
Error Output
Error: getDefaultAgent is not a function
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: Can not use OpenAI SDK with Sentry Node agent: TypeError: getDefaultAgent is not a function
As per Alex's comment from the Sentry package, this resolved the problem for me; [code block]
Trust Score
2 verifications
- 1
As per Alex's comment from the Sentry package, this resolved the problem for me;
As per Alex's comment from the Sentry package, this resolved the problem for me;
Validation
Resolved in openai/openai-node GitHub issue #1010. Community reactions: 1 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep