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

localVarFormParams.getHeaders is not a function

Open sidmohanty11 opened this issue 1 year ago • 2 comments

Describe the bug

When I am using OpenAI node SDK to createTranscription,

I am sending it the file like this,

  const mediaBlob = await fetch(url)
    .then(response => response.blob());

const audio = new File(
    [mediaBlob],
    'demo.mp4',
    { type: 'video/mp4' },
  );

const resp = await openai.createTranscription(audio, 'whisper-1'); // even audio.text(), stream() etc doesn't work

It's throwing me localVarFormParams.getHeaders is not a function

To Reproduce

  1. Try to send an audio file for transcription using openai.createTranscription
  2. Try to send a file
  3. Error thrown - localVarFormParams.getHeaders is not a function

Code snippets

No response

OS

macOS

Node version

Node v16.16.0

Library version

openai v3.2.1

sidmohanty11 avatar Mar 02 '23 09:03 sidmohanty11

I had the same issue. Same error with openai.createTranslation API

estepona avatar Mar 04 '23 21:03 estepona

Not a solution I recommend, but it does make the createTranscription function accessible. So for a testing/dev environment I don't see any harm 🙂

class CustomFormData extends FormData {
    getHeaders() {
        return {}
    }
}

const configuration = new Configuration({
    apiKey: process.env.OPENAI_API_KEY,
    formDataCtor: CustomFormData
})

JeffreyArts avatar Mar 14 '23 16:03 JeffreyArts

Not a solution I recommend, but it does make the createTranscription function accessible. So for a testing/dev environment I don't see any harm 🙂

class CustomFormData extends FormData {
    getHeaders() {
        return {}
    }
}

const configuration = new Configuration({
    apiKey: process.env.OPENAI_API_KEY,
    formDataCtor: CustomFormData
})

This fixed it, Thank you.

el7or avatar Mar 21 '23 08:03 el7or

I have the same Problem with createImageVariationes. I do ny app in react. Tried some way, always this error. No Syntax highlighting in WebStrom.

TomPeak avatar May 18 '23 04:05 TomPeak

Our upcoming v4 fixes this; please give it a try!

rattrayalex avatar Jul 10 '23 00:07 rattrayalex