File Upload API is not Working

Hi,
I am trying to upload a file sing the answers api through the following command.
curl https://api.openai.com/v1/files
-H “Authorization: Bearer $OPENAI_API_KEY”
-F purpose=“answers”
-F file=“@myfile.jsonl

But I am receiving the following error:
{
“error”: {
“message”: “‘answers’ is not one of [‘fine-tune’] - ‘purpose’”,
“type”: “invalid_request_error”,
“param”: null,
“code”: null
}
}

Can you please help me?

You could ask that question to our old friend “Chappie” ;-). He’s quite good at solving error codes.

Hi @sounak

The error message is clear, but it’s easy to miss if you are not used to reading error messages like this.

Change: 'answers' to 'fine-tune' to get past this error.

Hi @ruby_coder,
Thanks for the prompt reply.
I have changed the command as per your suggestion.

curl https://api.openai.com/v1/files -H "Authorization: Bearer $OPENAI_API_KEY
" -F purpose=“fine-tune” -F file=“myfile.jsonl”

But again receiving some error -
{
“error”: {
“message”: “The browser (or proxy) sent a request that this server could not understand.”,
“type”: “server_error”,
“param”: null,
“code”: null
}
}

Hi @sounak

The docs say:

curl https://api.openai.com/v1/files \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F purpose="fine-tune" \
  -F file='@mydata.jsonl'

Do you see what is different in the example than in your code?

Reference:

See Also:

OpenAI API Docs: File Upload

Hi @ruby_coder,
I am trying to upload some files through OpenAI api. Then I want to ask questions from those files and retrieve the answers. I was following OpenAI API documentation.
When I changed the purpose to ‘fine-tune’ from ‘answers’ it is showing an error message - ‘Missing prompt key on line 1.",’
It is obvious as I am not uploading any training data.
my data is of the following format -
{“text”: “”, “metadata”: “”}
{“text”: “”, “metadata”: “”}

Please help me.

The only permitted purpose (that I know of) for is “fine-tuning” .

Sorry I am at the gym and not my desk.

Okay, thanks for the reply.

Well, I’m back at my desk and in this case (above) your data is not in the correct JSONL format so you will get an error.

Look at this:

{“text”: “”, “metadata”: “”}

When you fine-tune, your data with the keys above, you will get errors for sure.

You must use this format (these exact keys):

{"prompt" : "your prompt goes here", "completion", "your completion goes here"}

The following keys (your keys above) are incorrect for fine-tuning:

{“text”: “”, “metadata”: “”}

See:

Reference:

OpenAI: Fine-Tuning

Okay, thanks for the reply.