Getting invalid_request_header from transcriptions endpoint

Hi there, I have been attempting to submit an audio file for transcription, and as far as I can tell, I’ve formatted the HTTP POST request correctly, but the server is responding with an error: “you must provide a model parameter”.

Here is the HTTP POST request:
[header]
POST /v1/audio/transcriptions HTTP/2
Host: api.openai.com
User-Agent: curl/8.4.0
Accept: */*
Authorization: Bearer [redacted]
Content-Length: 654410
Content-Type: multipart/form-data; boundary=F8DD6D1A-530A-464B-921D-1E30EC63F8A5

[body]
--F8DD6D1A-530A-464B-921D-1E30EC63F8A5
Content-Disposition: form-data; name="file", filename:"forTranscription.m4a"
Content-Type: audio/m4a

[binary data omitted for clarity]
--F8DD6D1A-530A-464B-921D-1E30EC63F8A5
Content-Disposition: form-data; name="model"

whisper-1
--F8DD6D1A-530A-464B-921D-1E30EC63F8A5--

Am I not formatting the request properly? Any suggestions as to how I might debug this would be appreciated.

1 Like

The server is responding with “you must provide a model parameter” because you must provide a model parameter.

You are proving multipart form data. One of the parts is the contents model="whisper-1"

Thanks -j. If you look at the output I provided, I do specify model=whisper-1. Do I need to do it somewhere else?

Doh. Figured it out. Several typos: after, name=“file”, I used a comma instead of a semi-colon; after filename, I used a colon, instead of an equals sign.

2 Likes

Just in case anybody else stumbles upon this topic because the server cannot parse your multipart/form request:

The OpenAI API currently cannot handle boundaries that include dashes (-). If you construct your request manually or the web client you use inserts dashes as part of the boundary, you might need to redefine these boundaries. I think this is a bug in the API since RFC1341 explicitly permits this:

boundary := 0*69<bchars> bcharsnospace 

bchars := bcharsnospace / " " 

bcharsnospace :=    DIGIT / ALPHA / "'" / "(" / ")" / "+"  / 
"_" 
               / "," / "-" / "." / "/" / ":" / "=" / "?" 

https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html#:~:text=bcharsnospace