Home > front end >  GPT-3 API invalid_request_error: you must provide a model parameter
GPT-3 API invalid_request_error: you must provide a model parameter

Time:09-28

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

CodePudding user response:

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

  • Related