Your feedback requested: Node.js SDK 5.0.0 alpha

Hey everyone!

We’re pleased to share that a new alpha of the 5.0.0 version of the JavaScript / TypeScript SDK is available on npm and in the alpha branch of the GitHub repository. This version of the SDK represents a breaking change to the existing 4.x SDK, as we have migrated completely to using built-in fetch for HTTP requests across all environments (Node.js, Deno, etc). However, we do expect that most of your code will “just work” with minor adjustments in types.

We would love your help and feedback on this new version - if you have any thoughts you’d like to share, please comment on this post.

Thanks in advance, and have a great holiday!

9 Likes

I really like it! I found it to be really cool to explore the changes at Comparing master...alpha · openai/openai-node · GitHub

after upgrading to 5.0.0 everything works perfectly!

2 Likes

Thank god for this. no one should use axios or node-fetch in 2024. I will switch to it today and report any issues on github.

Hi Team,

I am using 5.0.0-alpha.0
I don’t get this error in node version v18.17.0 but I get this error with node version v16.20.2.

fetch is not defined as a global; Either pass fetch to the client, new OpenAI({ fetch }) or polyfill the global, globalThis.fetch = fetch

Is this related to node version?

Hey @sudarsangp, yes this is related to your node version. We’re dropping all support for v16 as active support was dropped over 2 years ago. Our minimum supported version is v18.

You’ll have to use a polyfill if you want to continue using v16.

1 Like

I use it with Next.js. it’s so good cause prevent punycode warning!!

If you use beta feature such as vector stores, assitants, you should add header ’ ‘OpenAI-Beta: assistants=v2’'.

await openai.beta.vectorStores.files.createAndPoll(
		input.openAiVectorStoreId,
		{
			file_id: file.id,
		},
		{
			headers: {
				"OpenAI-Beta": "assistants=v2",
			},
		},
	);

1 Like

Ah thanks for the report, you shouldn’t have to specify the OpenAI-Beta header explicitly, that’s a bug. Will investigate!

1 Like