The Configuration lets you set a formDataCtor parameter to fix this.
So, add this to your code:
import FormData from "form-data";
class FData extends FormData {
append(key: string, value: any, options?: FormData.AppendOptions | string): void {
if (key === 'image') {
return super.append('image', value, {
contentType: 'image/png',
filename: 'img.png',
});
} else {
return super.append(key, value, options);
}
}
}
On your Configuration declaration, add a parameter formDataCtor: FData,
Should look like this:
const configuration = new Configuration({
apiKey: your_api_key,
formDataCtor: FData,
});
And done. Now you are able to simply pass a Buffer to the createImageVariation and createImageEdit methods like this: const ```TS
response = await openai.createImageVariation(imageBuffer, 1, '1024x1024');