openai-node
openai-node copied to clipboard
localVarFormParams.getHeaders is not a function
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
- Try to send an audio file for transcription using
openai.createTranscription
- Try to send a file
- 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
I had the same issue. Same error with openai.createTranslation API
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
})
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.
I have the same Problem with createImageVariationes. I do ny app in react. Tried some way, always this error. No Syntax highlighting in WebStrom.
Our upcoming v4 fixes this; please give it a try!