OpenAI Node SDK migration guide
Upgrade the openai npm package from 4.x to 5.x, then through later 5, 6 and 7 releases. Find breaking changes in your code and review supported fixes.
How can I detect breaking changes in the OpenAI Node SDK?
Emendant finds supported OpenAI Node SDK changes in TypeScript and JavaScript code. It covers the 4.x to 5.0 upgrade and selected later 5.x, 6.x and 7.x releases listed below. Run npx emendant scan from your repository, then review each affected code location and its release source with npx emendant explain <change-id>. Use the scan guide to read findings and coverage warnings. A clean scan does not cover changes absent from the feed.
Example: move a beta chat call in openai 5.0
In openai 5.0.0, beta.chat is removed. For a client created with new OpenAI(), Emendant can report this affected call and offer a deterministic rename:
Before the upgrade:
import OpenAI from "openai";
const client = new OpenAI();
await client.beta.chat.completions.parse({
model: "gpt-4o", messages: [],
});Possible fix for 5.0:
await client.chat.completions.parse({
model: "gpt-4o", messages: [],
});The OpenAI v5 migration source confirms this move. Review the 5.0 coverage and remaining changes. Related type imports also move and need review. An ambiguous client binding can prevent detection. Inspect possible patches with npx emendant fix --dry-run; a preview checks structure but does not install the target SDK or run your typecheck and tests. Run your typecheck and tests against the target SDK before you apply a patch.
Choose your OpenAI Node SDK migration path
The openai package is the OpenAI library for TypeScript and JavaScript. Start with the release you are moving to. The 5.0 guide covers the major upgrade, which changes calls and imports. Later pages cover selected changes to request types, client options or runtime requirements.
- Migrate openai 4.x to 5.0:
beta.chatmoves tochat,fileFromPath, the shims andrunFunctionsare removed, andopenai/srcno longer resolves. Read it with the OpenAI v5 migration guide. - Later 5.x, 6.x and 7.x releases: pages cover selected changes to request fields, client options or runtime requirements. Most add an accepted value. Some rename or deprecate one, such as
prompt_cache_retentionin 6.35.0 and Videos in 7.5.0. Read the page for each release between your current version and your target. The list is below.
Check your repository before you upgrade
- Check the installed
openaiversion in your manifest and lockfile. Read each guide between that version and your target. - Run
npx emendant scanin your TypeScript or JavaScript repository. It reports supported changes at affected call sites without editing your files. - Review the findings, then run
npx emendant fix --dry-runto inspect eligible patches. Emendant does not update package versions for you. - After you update dependencies, run your own typecheck and tests.
What Emendant fixes, and the gaps
- In 5.0, transforms patch the
beta.chatrename, the move toopenai/corepaths and theopenai/srcimports. The other 5.0 changes need a model provider you name, or are report only. - The type changes in later releases are patched only when you name a model provider. The Videos deprecation in 7.5.0 is report only.
- The feed has no entry for openai 6.0.0. The 7.0.0 entry checks the tighter Node.js requirement only and offers no patch. Read the 6.0.0 and 7.0.0 release notes before you upgrade past them.
Emendant reports only changes in its curated feed. A clean scan does not prove that every OpenAI SDK migration step is complete. Read the supported projects guide for the current scope, the fix guide for patch grades, and whether AI-generated migration patches are safe.
Reviewing a dependency update PR? Follow Use Emendant alongside Dependabot to scan affected code, review possible patches, and check the remaining migration work.
OpenAI Node SDK release pages
- openai 7.x breaking changes: 7.2.0 to 7.51.0
7 releases, 7.2.0 to 7.51.0, released 30 July 2026 to 5 November 2026. 14 breaking, 1 deprecation. - openai 7.0.0: Node 22 or later required
openai 7.0.0, released 27 July 2026. 1 breaking, 0 deprecations. - OpenAI Node SDK 6.x breaking changes: 6.3.0 to 6.49.0
11 releases, 6.3.0 to 6.49.0, released 10 October 2025 to 23 July 2026. 17 breaking, 0 deprecations. - OpenAI Node SDK 5.x breaking changes: 5.4.0 to 5.18.0
3 releases, 5.4.0 to 5.18.0, released 16 June 2025 to 2 September 2025. 6 breaking, 0 deprecations. - openai 5.0.0: beta.chat and upload migration
openai 5.0.0, released 29 May 2025. 10 breaking, 1 deprecation.
Releases without a page here may still be in the feed. Run emendant feed status to see what your snapshot holds.