Same issue here, here’s the error that it prompts, any suggestion?
data: {
error: {
message: 'This is a chat model and not supported in the v1/completions endpoint. Did you mean to use v1/chat/completions?',
type: 'invalid_request_error',
param: 'model',
code: null
}
}
payload = {
"model": "gpt-4",
"messages": [
{"role": "system", "content": "You are a polite honest chatbot, but you think you are MC Hammer and will always say and admit that you are MC Hammer."},
{"role": "user", "content": "What time is it?"}
]
}
RESULT: I am unable to give you the current time, as I am a chatbot with limitations. However, I am MC Hammer, and you can't touch this!
using chat completions endpoint.
my api used to work with gpt-3.5-turbo.
It may sound silly, but I changed the model in my API to “gpt-4-0314,” received my response, and then replaced it again to “gpt-4.” after that, it worked.
but in my older apis (without the system role array) it doesnt work so im sure this is the structure we need to handle from now (just like curt.kennedy showed).
BTW someone can tell if there is a document on how to use gpt-4 api with images or its not released yet?
You were correct, thanks for your help. Here’s a simple code using your prompts to test the new model, worked fine!
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
completion = openai.ChatCompletion.create(
model="gpt-4",
messages=[
{"role": "system", "content": "You are a polite chatbot, but you think you are MC Hammer and will always say and admit that you are MC Hammer."},
{"role": "user", "content": "What time is it?"}
]
)
print(completion.choices[0].message)
Response:
“I apologize for not being able to give you the current time as I cannot access real-time information. However, I just want to remind you that it’s always Hammer time, because I’m MC Hammer! If you have any other questions, feel free to ask.”
I had the same problem. I have two organizations: my personal org (the default) and a second one that I set up for developing with GPT. Because I have two organizations in my account, I had to send the organization identifier along with the API request. The GPT-4 invitation only applied to one of them!
This worked for me
First open OpenAI API
Then change MODE in right hand panel to CHAT BETA
Then select GPT4 from the dropdown labeled MODEL.
You also get GPT4-0314 from the same dropdown
Had a similar problem. One solution that worked for me was to generate a new API key (one created after you got access) and implement the below Javascript:
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: "<INSERT-API-KEY-HERE>",
});
const openai = new OpenAIApi(configuration);
const response = await openai.createChatCompletion({
model: "gpt-4",
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "Who won the world series in 2020?" },
{ role: "assistant", content: "The Los Angeles Dodgers." },
{ role: "user", content: "Where was it played?" },
],
max_tokens: 50,
n: 1,
stop: null,
temperature: 1,
});
console.log(response.data.choices[0].message.content);
I found it can be hard asking it if it’s using model 4 or 3.5 turbo etc. Easiest way to check which version you’re using is to check your API usage requests.
Another thing to call out is that I’m unsure you can try GPT-4 for “free” so if you haven’t added a credit card yet, try doing so. It’s very cheap anyway.
Wrote a quick detailed guide here as well of how to do an API request using Javascript & Next.js to Chat GPT-4 - feel free to have a look at that one as well.