Currently working on a project with GPT completions and it worked perfectly fine with the model set as “text-davinci-003” but when I changed it to “gpt-4” it stopped working and I’m getting the error I set in my code. BTW I have the beta invite to gpt 4 api.
Here’s a snippet from my code:
response = requests.post("https://api.openai.com/v1/completions", json={
"model": "gpt-4",
"prompt": prompt,
"max_tokens": 8000,
"n": 1,
"stop": None,
"temperature": 0.3,
}, headers={
"Content-Type": "application/json",
"Authorization": f"Bearer {API_KEY}"
})
response_data = response.json()
if 'choices' in response_data:
definition = response_data['choices'][0]['text'].strip()
else:
definition = "Error: Could not get a translation."
I believe GPT 4 isn’t available yet for regular completions, only chat completions.
If you reformat your request to have the format of the Chat endpoint, then it should work!
There are a few notes in the documentation about this.
Hi
If you are getting the same error you may not have access to gpt-4. I don’t have access and I get that error too via the same chat/completions end point.