const configuration = new Configuration({
apiKey: API_KEY,
});
// ......
try {
const completion = await openai.createCompletion({
model: MODEL,
prompt: prompt_wrapper(prompt),
temperature: 0.2,
});
const final = final_wrapper(completion.data.choices[0].message.content);
return resolve(final);
} catch (error) {
if(error.response.status == 429) {
console.error(`Rate limited`)
for(const [key, value] of Object.entries(error.response.headers))
console.warn(`${key}=${value}`);
return resolve('You have reached the rate limit')
}
console.error(error) //the error is coming from here I believ
return resolve("API Error");
}
Rate limited
date=Fri, 09 Jun 2023 14:28:38 GMT
content-type=application/json; charset=utf-8
content-length=206
connection=keep-alive
vary=Origin
x-request-id=5193a4e8b45007097d2879427e19f07b
strict-transport-security=max-age=15724800; includeSubDomains
cf-cache-status=DYNAMIC
server=cloudflare
cf-ray=7d4a0fe8e8890ab9-MAN
alt-svc=h3=":443"; ma=86400
Confused to whats going on, the API key is correct, I just made a free one. I am using the ada model