openai-node icon indicating copy to clipboard operation
openai-node copied to clipboard

replace axios with fetch

Open dominiksipowicz opened this issue 2 years ago • 3 comments

Describe the feature or improvement you're requesting

  • Axios is not compatible with other runtimes (for example Edge).
  • Significant reduction in size
  • Fetch support for all runtimes (browser, node, edge, deno, workers)
  • The fetch lib could optionally be passed as a dependency

ref: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API

Additional context

When running current version with axios on the Edge I got this error:

An error occurred during OpenAI request [TypeError: adapter is not a function]

dominiksipowicz avatar Jan 11 '23 01:01 dominiksipowicz

@dominiksipowicz temporary solution: https://github.com/dan-kwiat/openai-edge

dan-kwiat avatar Jan 13 '23 10:01 dan-kwiat

@dan-kwiat

temporary solution: https://github.com/dan-kwiat/openai-edge

Wow, that was quick. This is a great start. At this point, I just call directly REST endpoints with native fetch so it's a super nice thing to have!

dominiksipowicz avatar Jan 13 '23 16:01 dominiksipowicz

Here it is 🎉 cc @dominiksipowicz : https://github.com/openai/openai-node/pull/45#issuecomment-1371569799

gfortaine avatar Jan 17 '23 14:01 gfortaine

Hi all, we have an upcoming version v4.0.0 that uses fetch and works on Edge runtimes; please give it a try and let us know in the thread whether it suits your needs!

rattrayalex avatar Jun 27 '23 21:06 rattrayalex