Below is my code... and I am looking at the API usage on the openai console and I am way under the limit. I haven't ever been able to get a sucessful response. I am copying the code from their documentation. I keep getting a HTTP 429
const API_URL = "<https://api.openai.com/v1/chat/completions>";
const API_KEY = "YOUR_API_KEY";
const generate = async () => {
try {
// Fetch the response from the OpenAI API with the signal from AbortController
const response = await fetch(API_URL, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${API_KEY}`,
},
body: JSON.stringify({
model: "gpt-3.5-turbo",
messages: [{ role: "user", content: promptInput.value }],
}),
});
const data = await response.json();
resultText.innerText = data.choices[0].message.content;
} catch (error) {
console.error("Error:", error);
resultText.innerText = "Error occurred while generating.";
}
};