How to upload a file in a POST request without using Python/Node.js APIs?


I try to find information on the “file” fields for ex to upload a file for an audio/transcriptions endpoint.

I am using a proprietary API to do RESTful queries (not using CURL / Python / Node / etc)

We can do multipart/form-data content type, but I don’t understand how to link the “file” field to the HTTP part.

Can someone point me to the API ref doc page explains how to send binary content is such POST request?


The file parts are boundary-delineated MIME encoded (the MIME standard of email).

If you want to write your own HTTP multipart/form-data sender, you have to start at a very low level that is not specific to OpenAI.


Thanks for your quick answer _j, but can you clarify what I should put in the “file” field of the JSON structure ?
According to the OpenAI API spec, it’s required .

Maybe the multipart part should have an HTTP header

Content-Disposition: form-data; name=“file”


There is no RESTful JSON with multipart. Each “parameter” is a form part (as if someone is submitting a web form).

I’ve found the CURL documentation most helpful in giving an overview of the -F parameters and how they are constructed. You can then decide “aha, this is something someone else has already written, I don’t need to write my own http browser just to send an API some data.”

1 Like

Ahhhhh! OK now I got it!
So no JSON structure to send as payload,
The OpenAI API reference doc should be clear about this.
It’s not obvious.
Thanks a lot, will try now.

1 Like