I am using the Python version of the OpenAI API and trying to upload a file with the following code:
client.files.create(file=myFile, purpose="fine-tune")
The client has been initialized with a valid API key, and other calls to the API (to send text prompts) work correctly, but when I try to post a file I get a "HTTP/1.1 400 Bad Request" error.
I have verified that the file exists and is a readable text file (the code logs the first line of the file before posting it).
The code used to initialize myFile is:
myFile = open(file_path, "rb");
What could the problem be?
As stated by @codenanda, I was using the wrong file format. The current version of the OpenAI API only supports JSON files.