What is the correct format for the JSON Lines file used for getting answers?

I am trying to understand how to use the Files API by following this article.

For the initial test I am using a .jsonl file that looks exactly like the one in the article:

{"text": Google was founded in 1998 by Larry Page and Sergey Brin while they were Ph.D. students at Stanford University in California. Together they own about 14 percent of its shares and control 56 percent of the stockholder voting power through supervoting stock. They incorporated Google as a privately held company on September 4, 1998. An initial public offering (IPO) took place on August 19, 2004, and Google moved to its headquarters in Mountain View, California, nicknamed the Googleplex. In August 2015, Google announced plans to reorganize its various interests as a conglomerate called Alphabet Inc. Google is Alphabet's leading subsidiary and will continue to be the umbrella company for Alphabet's Internet interests. Sundar Pichai was appointed CEO of Google, replacing Larry Page who became the CEO of Alphabet.", "metadata": "Google"}
{"text": "Amazon is an American multinational technology company based in Seattle, Washington, which focuses on e-commerce, cloud computing, digital streaming, and artificial intelligence. It is one of the Big Five companies in the U.S. information technology industry, along with Google, Apple, Microsoft, and Facebook. The company has been referred to as 'one of the most influential economic and cultural forces in the world', as well as the world's most valuable brand.Jeff Bezos founded Amazon from his garage in Bellevue, Washington on July 5, 1994. It started as an online marketplace for books but expanded to sell electronics, software, video games, apparel, furniture, food, toys, and jewelry. In 2015, Amazon surpassed Walmart as the most valuable retailer in the United States by market capitalization.", "metadata": "Amazon"}

I am using Postman as an API Client and the response indicates that the server did not receive a correct JSONL file. The raw log is as follows:

POST https://api.openai.com/v1/files
400
772 ms
POST /v1/files HTTP/1.1
Authorization: Bearer ***
User-Agent: PostmanRuntime/7.26.8
Accept: */*
Cache-Control: no-cache
Postman-Token: cef7e723-2f0d-4b6e-afa0-beffcc31e02b
Host: api.openai.com
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Type: multipart/form-data; boundary=--------------------------096423338688456968322180
Content-Length: 2030
----------------------------096423338688456968322180
Content-Disposition: form-data; name="purpose"

answers
----------------------------096423338688456968322180
Content-Disposition: form-data; name="file"; filename="qa_sample.jsonl"

<qa_sample.jsonl>
----------------------------096423338688456968322180--
HTTP/1.1 400 BAD REQUEST
Server: nginx/1.17.10
Date: Sun, 13 Jun 2021 07:36:23 GMT
Content-Type: application/json
Content-Length: 135
Connection: keep-alive
Access-Control-Allow-Origin: *
OpenAI-Version: 2020-10-01
OpenAI-Organization: user-l7r5jgn3tlzwte54di5nu6ss
X-Request-ID: a70c1c2c479a612863a55bf24bba2f2a
OpenAI-Processing-Ms: 210
Strict-Transport-Security: max-age=15724800; includeSubDomains
{
  "error": {
    "code": null,
    "message": "Expected a JSONL file.",
    "param": null,
    "type": "invalid_request_error"
  }
}

I have replaced Windows \r\n with \n, but newlines do not seem to matter.
The automatically generated curl is the following:

curl --location --request POST 'https://api.openai.com/v1/files' \
--header 'Authorization: Bearer ***' \
--form 'purpose="answers"' \
--form 'file=@"/D:/Projects/OpenAI/Files/qa_sample.jsonl"'

Note: Postman is allowed to read files outside working directory, so this issue was already tackled.

Any idea about how to manage to upload files to OpenAI?

Did not notice that. It works as expected and it appears in the file list upon upload. Thank you.

1 Like