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

400 Missing required parameter: 'messages[1].content[0].file.file_id'

Open vitorbarbosa19 opened this issue 8 months ago • 2 comments

Confirm this is a Node library issue and not an underlying OpenAI API issue

  • [x] This is an issue with the Node library

Describe the bug

The correct name of the property in order to send Base64-encoded files via the completions API is filename not file_name as described in the documentation. From OpenAI's tutorial you can see the property name is incorrect. See print below.

Image

It can be seen in the print below, taken from the Playground, that the frontend is sending filename instead.

Image

The problem with fixing the property name in our own codebase is that Typescript considers it an error. See print below.

Image

The solution is to either fix the name of the type declaration.

To Reproduce

Simply call the completions API trying to send Base64-encoded files. Follow the documentation here and you'll reproduce the error.

Code snippets


OS

macOS

Node version

20.0.0

Library version

4.87.3

vitorbarbosa19 avatar Mar 18 '25 14:03 vitorbarbosa19

To anyone looking for a quick solution to this, just rename the property from file_name to filename and add a // @ts-ignore or // @ts-expect-error above the type property.

vitorbarbosa19 avatar Mar 18 '25 14:03 vitorbarbosa19

Thanks for the report - fix incoming in the next point release

kwhinnery-openai avatar Mar 18 '25 15:03 kwhinnery-openai

I believe it has been fixed already

Image

I am trying really hard to find a good issue to fix as I have been offproject for a week, but damn, it is either a user misuse or an old problem already fixed!

Lucas-Levandoski avatar Apr 11 '25 14:04 Lucas-Levandoski