Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GPT-3 API invalid_request_error: you must provide a model parameter

I'm new to APIs and I'm trying to understand how to get a response from a prompt using OpenAI's GPT-3 API (using api.openai.com/v1/completions). I'm using Postman to do so. The documentation says that there is only one required parameter, which is the "model." However, I get an error saying that "you must provide a model parameter," even though I already provided it.

What am I doing wrong?

API error screenshot

like image 707
David A. Avatar asked Dec 13 '25 06:12

David A.


2 Answers

You can get this to work the following way in Postman with the POST setting:

  1. Leave all items in the Params tab empty

  2. In the Authorization tab, paste your OpenAI API token as the Type Bearer Token (as you likely already did)

  3. In the Headers tab, add key "Content-Type" with value "application/json"

  4. In the Body tab, switch to Raw, and add e.g.

     {  
         "model":"text-davinci-002",
         "prompt":"Albert Einstein was"
     }
    
  5. Hit Send. You'll get back the completions for your prompt.

Note alternatively, you can add the model into the Post URL, like https://api.openai.com/v1/engines/text-davinci-002/completions

While above works, it might not be using the Postman UI to its full potential -- after all, we're raw-editing JSON instead of utilizing nice key-value input boxes. If you find out how to do the latter, let us know.

enter image description here

like image 175
Philipp Lenssen Avatar answered Dec 15 '25 23:12

Philipp Lenssen


What solved it for me was adding the content-type header: "content-type:application/json"

postman-headers

like image 40
Tom Avatar answered Dec 16 '25 00:12

Tom



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!