#8694 OpenAI package incompatibility with Cloudflare Workers
OpenAI SDK officially supports CF Workers. Works correctly in testing with nodejs_compat flag. Issue lacks wrangler.toml, error logs, reproduction. Likely configuration issue, not bug.
Request wrangler.toml, error logs, verify nodejs_compat flag. Close if no response in 30 days.
Analysis Report
Issue Review: cloudflare/workers-sdk#8694
Summary
OpenAI SDK (v4.89.1) returns 500 errors when deployed to Cloudflare Workers, while endpoints without OpenAI work normally. Reporter suspects Node.js compatibility issues.
Findings
- Created: 2025-03-27
- Updated: 2025-10-30
- Version: Wrangler 4.5.0 (reported) → 4.60.0 (current)
- Component: Wrangler / Workers Runtime
- Labels: bug, workers ai
- Comments: 0
Key Evidence
OpenAI SDK officially supports Cloudflare Workers: The npm package documentation explicitly lists "Cloudflare Workers" as a supported runtime under the Requirements section.
Cloudflare has official documentation for OpenAI SDK: The Cloudflare Workers documentation provides working examples of using the OpenAI SDK with Workers.
Configuration requirements: The OpenAI SDK requires the
nodejs_compatcompatibility flag and a compatibility date of2024-09-23or later for full Node.js API support.Reproduction test results:
- With proper configuration (
nodejs_compatflag +2024-09-23compatibility date): OpenAI SDK works correctly - Without
nodejs_compat: In latest wrangler (4.60.0), basic calls still work due to improved polyfill support - API calls correctly fail only with authentication errors (expected behavior with test key)
- With proper configuration (
Issue lacks critical details:
- No
wrangler.tomlconfiguration provided - No error logs provided (field left empty)
- No minimal reproduction provided
- No confirmation of
nodejs_compatflag usage - No information about whether issue occurs in dev or deployed environment
- No
unenv-preset updates since 4.5.0: Multiple releases of
@cloudflare/unenv-presethave improved Node.js compatibility (2.3.0 → 2.11.0), particularly fornode:tlsandnode:cryptomodules.
Recommendation
Status: NEEDS MORE INFO
Reasoning: The OpenAI SDK is officially supported on Cloudflare Workers and works correctly with proper configuration. The issue lacks the essential details needed to reproduce the problem: no wrangler.toml configuration (to verify nodejs_compat flag is enabled), no error logs, and no minimal reproduction. Given that 10 months have passed without any comments or additional context, and that the SDK works correctly in testing with the latest wrangler version, this appears to be a configuration issue rather than a bug.
Action: Request essential debugging information from the reporter. If no response within 30 days, close as insufficient information.
Suggested Comment
Hi @[reporter],
Thank you for reporting this issue. The OpenAI SDK is officially supported on Cloudflare Workers and should work correctly with the proper configuration.
To use the OpenAI SDK (v4+) with Cloudflare Workers, you need to enable Node.js compatibility in your
wrangler.toml:compatibility_date = "2024-09-23" compatibility_flags = ["nodejs_compat"]I tested the OpenAI SDK with the latest wrangler (4.60.0) and it works correctly both for client instantiation and API calls.
Could you please provide:
- Your complete
wrangler.tomlconfiguration (with any secrets redacted)- The actual error logs/messages you're seeing (the "500 error" details)
- Whether this occurs in
wrangler dev(local), or only when deployedAdditionally, please try updating to the latest wrangler version and ensuring you have the
nodejs_compatflag enabled.Here's a working example for reference:
Notes & Feedback (0)
No notes yet.