0

I am trying to make an API call to GPT-3 but I am getting an error (Bad request 400). Here is my code:

url = "https://api.openai.com/v1/engines/gpt-3/jobs"

headers = {
    "Content-Type": "application/json",
    "Authorization": "sk-apikey"
}

data = {
    "model": "text-davinci-002",
    "prompt": "Correct this to standard English : Who are you",
    "max_tokens": 60        
}

response = requests.post(url, headers=headers, data=json.dumps(data))
mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Kaptan Singh
  • 221
  • 1
  • 3
  • 11
  • Does this answer your question? [OpenAI API error: "Cannot specify both model and engine"](https://stackoverflow.com/questions/75176667/openai-api-error-cannot-specify-both-model-and-engine) – Rok Benko Feb 06 '23 at 14:09

1 Answers1

1

Try changing the url and fixing the Authorization header...

url = "https://api.openai.com/v1/completions"

headers = {
    "Content-Type": "application/json",
    "Authorization": f"Bearer {api_key}"
}

data = {
    "model": "text-davinci-002",
    "prompt": "Correct this to standard English : Who are you \n",
    "max_tokens": 60        
}

response = requests.post(url, headers=headers, data=json.dumps(data))
response.json()
Pedro Rocha
  • 1,373
  • 1
  • 3
  • 14