# File Upload API is not Working

**URL:** <https://community.openai.com/t/file-upload-api-is-not-working/43903>\
**Category:** API\
**Created:** [January 24, 2023, 12:57pm UTC](https://community.openai.com/t/file-upload-api-is-not-working/43903 "2023-01-24T12:57:58Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![sounak](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/sounak/32/19769_2.png) [@sounak](https://community.openai.com/u/sounak)\
**Post date:** [January 24, 2023, 12:57pm UTC](https://community.openai.com/t/file-upload-api-is-not-working/43903/1 "2023-01-24T12:57:58Z")

</div>

Hi,  
I am trying to upload a file sing the answers api through the following command.  
curl [https://api.openai.com/v1/files](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?

---

<div class="post-metadata">

**Author:** ![amra.dorjbayar](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/amra.dorjbayar/32/17013_2.png) [@amra.dorjbayar](https://community.openai.com/u/amra.dorjbayar)\
**Post date:** [January 24, 2023, 1:22pm UTC](https://community.openai.com/t/file-upload-api-is-not-working/43903/2 "2023-01-24T13:22:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ruby\_coder](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/ruby_coder/32/19875_2.png) [@ruby\_coder](https://community.openai.com/u/ruby_coder)\
**Post date:** [January 24, 2023, 1:44pm UTC](https://community.openai.com/t/file-upload-api-is-not-working/43903/3 "2023-01-24T13:44:07Z")

</div>

> [@sounak](#):
>
> “message”: “‘answers’ is not one of [‘fine-tune’] - ‘purpose’”,

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.

---

<div class="post-metadata">

**Author:** ![sounak](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/sounak/32/19769_2.png) [@sounak](https://community.openai.com/u/sounak)\
**Post date:** [January 25, 2023, 4:56am UTC](https://community.openai.com/t/file-upload-api-is-not-working/43903/4 "2023-01-25T04:56:44Z")

</div>

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

curl [https://api.openai.com/v1/files](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  
}  
}

---

<div class="post-metadata">

**Author:** ![ruby\_coder](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/ruby_coder/32/19875_2.png) [@ruby\_coder](https://community.openai.com/u/ruby_coder)\
**Post date:** [January 25, 2023, 5:09am UTC](https://community.openai.com/t/file-upload-api-is-not-working/43903/5 "2023-01-25T05:09:27Z")

</div>

Hi @sounak

The docs say:

```shell
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:

 ![Screenshot 2023-01-25 at 12.08.43 PM](https://us1.discourse-cdn.com/openai1/original/3X/d/d/dda04703f78f5c291f377452aac17dc30698638e.png)

See Also:

[OpenAI API Docs: File Upload](https://beta.openai.com/docs/api-reference/files/upload)

---

<div class="post-metadata">

**Author:** ![sounak](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/sounak/32/19769_2.png) [@sounak](https://community.openai.com/u/sounak)\
**Post date:** [January 27, 2023, 6:05am UTC](https://community.openai.com/t/file-upload-api-is-not-working/43903/6 "2023-01-27T06:05:47Z")

</div>

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](https://beta.openai.com/docs/guides/answers) 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.

---

<div class="post-metadata">

**Author:** ![ruby\_coder](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/ruby_coder/32/19875_2.png) [@ruby\_coder](https://community.openai.com/u/ruby_coder)\
**Post date:** [January 27, 2023, 6:20am UTC](https://community.openai.com/t/file-upload-api-is-not-working/43903/7 "2023-01-27T06:20:50Z")

</div>

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

Sorry I am at the gym and not my desk.

---

<div class="post-metadata">

**Author:** ![sounak](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/sounak/32/19769_2.png) [@sounak](https://community.openai.com/u/sounak)\
**Post date:** [January 27, 2023, 6:57am UTC](https://community.openai.com/t/file-upload-api-is-not-working/43903/8 "2023-01-27T06:57:37Z")

</div>

Okay, thanks for the reply.

---

<div class="post-metadata">

**Author:** ![ruby\_coder](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/ruby_coder/32/19875_2.png) [@ruby\_coder](https://community.openai.com/u/ruby_coder)\
**Post date:** [January 27, 2023, 9:16am UTC](https://community.openai.com/t/file-upload-api-is-not-working/43903/9 "2023-01-27T09:16:18Z")

</div>

> [@sounak](#):
>
> {“text”: “”, “metadata”: “”}  
> {“text”: “”, “metadata”: “”}

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:

```auto
{“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):

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

```

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

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

```

See:

 ![Screenshot 2023-01-27 at 4.14.59 PM](https://us1.discourse-cdn.com/openai1/original/3X/e/a/ea19f74c69956c1806b611c9561526ad2ed7955d.png)

Reference:

[OpenAI: Fine-Tuning](https://beta.openai.com/docs/guides/fine-tuning)

---

<div class="post-metadata">

**Author:** ![sounak](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/sounak/32/19769_2.png) [@sounak](https://community.openai.com/u/sounak)\
**Post date:** [January 27, 2023, 9:17am UTC](https://community.openai.com/t/file-upload-api-is-not-working/43903/10 "2023-01-27T09:17:20Z")

</div>

Okay, thanks for the reply.

---

<div class="post-metadata">

**Author:** ![curt.kennedy](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/curt.kennedy/32/709249_2.png) [@curt.kennedy](https://community.openai.com/u/curt.kennedy)\
**Post date:** [December 17, 2023, 6:09pm UTC](https://community.openai.com/t/file-upload-api-is-not-working/43903/11 "2023-12-17T18:09:56Z")

</div>


