Workers SDK Issue Reports

← Back to Dashboard

#8694 OpenAI package incompatibility with Cloudflare Workers

Download Reproduction
Recommendation:NEEDS MORE INFO
Difficulty:n/a
Reasoning:

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.

Suggested Action:

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

  1. OpenAI SDK officially supports Cloudflare Workers: The npm package documentation explicitly lists "Cloudflare Workers" as a supported runtime under the Requirements section.

  2. Cloudflare has official documentation for OpenAI SDK: The Cloudflare Workers documentation provides working examples of using the OpenAI SDK with Workers.

  3. Configuration requirements: The OpenAI SDK requires the nodejs_compat compatibility flag and a compatibility date of 2024-09-23 or later for full Node.js API support.

  4. Reproduction test results:

    • With proper configuration (nodejs_compat flag + 2024-09-23 compatibility 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)
  5. Issue lacks critical details:

    • No wrangler.toml configuration provided
    • No error logs provided (field left empty)
    • No minimal reproduction provided
    • No confirmation of nodejs_compat flag usage
    • No information about whether issue occurs in dev or deployed environment
  6. unenv-preset updates since 4.5.0: Multiple releases of @cloudflare/unenv-preset have improved Node.js compatibility (2.3.0 → 2.11.0), particularly for node:tls and node:crypto modules.

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:

  1. Your complete wrangler.toml configuration (with any secrets redacted)
  2. The actual error logs/messages you're seeing (the "500 error" details)
  3. Whether this occurs in wrangler dev (local), or only when deployed

Additionally, please try updating to the latest wrangler version and ensuring you have the nodejs_compat flag enabled.

Here's a working example for reference:

Notes & Feedback (0)

No notes yet.

Add Note