I recently got the email saying I’m invited to use the GPT-4 models with 8K context API.
However, when I run my code with gpt-4
as the model, it throws a 404 error
. Using the same code for gpt-3.5-turbo
works.
Here’s a snippet of the code I’m using:
const config = {
method: "post",
url: "https://api.openai.com/v1/chat/completions",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${process.env.OPENAI_API_KEY}`,
},
data: {
model: "gpt-4",
messages,
max_tokens: 250,
n: 1,
temperature: 0.7,
frequency_penalty: 0,
presence_penalty: 0,
},
};
try {
const response = await axios(config);
const completion = response.data.choices[0].message.content;
return completion;
} catch (error) {
console.error("Error: ", error);
return "Sorry, I could not generate a response.";
}
Here’s the error:
response: {
status: 404,
statusText: 'Not Found',
headers: AxiosHeaders {
date: 'Mon, 08 May 2023 01:29:05 GMT',
'content-type': 'application/json; charset=utf-8',
'transfer-encoding': 'chunked',
connection: 'close',
vary: 'Origin',
'x-request-id': '0b6e57a26ca79e3ad5751a6fa7e2684c',
'strict-transport-security': 'max-age=15724800; includeSubDomains',
'cf-cache-status': 'DYNAMIC',
server: 'cloudflare',
'cf-ray': '7c3dee012e57334e-EWR',
'alt-svc': 'h3=":443"; ma=86400, h3-29=":443"; ma=86400'
},
config: {
transitional: [Object],
adapter: [Array],
transformRequest: [Array],
transformResponse: [Array],
timeout: 0,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
maxBodyLength: -1,
env: [Object],
validateStatus: [Function: validateStatus],
headers: [AxiosHeaders],
method: 'post',
url: 'https://api.openai.com/v1/chat/completions',
data: `{"model":"gpt-4-0314","messages":[{"role":"system","content"...