Invalid request error with text-davincii-3 query: "you must provide a model parameter"

Hi,

My query is getting an error, but I don’t understand why.

In postman, I queried the following:

Endpoint: https://api.openai.com/v1/completions

Headers
{Content-Type: “application/json”,
Authorization: “Bearer [mykey]”}

Parameters
{model: text-davinci-003,
top_p:1,
prompt: “hello”,
temperature: 0.29,
max_tokens: 5,
logprobs: 10,
frequency_penalty: 0,
presence_penalty: 0}

I am getting this error:
{
“error”: {
“message”: “you must provide a model parameter”,
“type”: “invalid_request_error”,
“param”: null,
“code”: null
}
}

This same query worked a few months ago and my OpenAI tokens have not expired.
I was wondering if anybody knows if the endpoints or parameters for text-davinci-003 (or 002) have changed at all?

Thanks for reading! Would appreciate any guidance.
Saachi

Welcome to the forum. Here’s the current endpoints…

Looks like your code is okay on a quick glance. Is it working via Playground? Can you cURL to the endpoint as another test?

Thank you!

It is working via playground and when I curl to the endpoint!

In Postman, I still get the error.

In Java, I use Unirest to call the API and the httpResponse is Null.
Here’s the code:

 try {
                httpResponse = Unirest.post("https://api.openai.com/v1/completions")
                    .header("Content-Type", "application/json")
                    .header("Authorization", secret_key)
                    .body("{\"model\":\"text-davinci-003\"," +
                            "\"prompt\":\""+params[0]+"\"," +
                            "\"temperature\":0.29," +
                            "\"top_p\":1," +
                            "\"frequency_penalty\":0," +
                            "\"presence_penalty\":0," +
                            "\"max_tokens\":5, " +
                            "\"logprobs\":10}")
                        .asJson();
            } catch (UnirestException e) {
                e.printStackTrace();
            }

Are you sending your API key somewhere? You need to authorize…

Try putting the model name in quotes

It may be treating text and davinci as variables and trying to subtract 003 from the result of zero

It may not be picked up by your programming language

This would probably produce an overall model name of “-3” instead of “text-davinci-003” if the dashes are interpreted at minus signs

Sorry - while reformatting, I deleted the headers. Edited it now.

I don’t quite understand. Do you mean to remove the backslashes escaping the double quotes around “text-davinci-003”? If so, when I do that, it closes the double quote that opens the query inside .body(), so it produces an error.

When I escape the dash, i get an “illegal escape character in string literal” error.

No your original post didn’t include quotes. Ignore my comment now the headers have been edited