Which model to use when u sending an response to chatgpt

I have a code that have a windows then when i press enter it sends the text i typed in a text box to the server , but always it says “insufficient_quota” do anyone have a reason to this, in my api key section it says the api keys was never used, heres the code

const apiKey = “My_key_thats_removed”;

const mainContainer = document.createElement(“div”);
mainContainer.style.position = “fixed”;
mainContainer.style.background = “rgba(0, 0, 0, 0.5)”;
mainContainer.style.color = “#fff”;
mainContainer.style.padding = “10px”;
mainContainer.style.zIndex = “999999”;
mainContainer.style.top = “50px”;
mainContainer.style.left = “50px”;
mainContainer.style.display = “flex”;
mainContainer.style.flexDirection = “column”;
mainContainer.style.alignItems = “flex-start”;

document.body.appendChild(mainContainer);

const headerText = document.createElement(“div”);
headerText.textContent = “ChatGPT Response:”;
headerText.style.fontSize = “20px”;
headerText.style.marginBottom = “10px”;
mainContainer.appendChild(headerText);

const inputBox = document.createElement(“input”);
inputBox.setAttribute(“type”, “text”);
inputBox.setAttribute(“placeholder”, “Enter a question”);
inputBox.style.marginBottom = “10px”;
mainContainer.appendChild(inputBox);

const enterButton = document.createElement(“button”);
enterButton.textContent = “Ask ChatGPT”;
mainContainer.appendChild(enterButton);

const resultDiv = document.createElement(“div”);
resultDiv.style.maxHeight = “300px”;
resultDiv.style.overflowY = “scroll”;
mainContainer.appendChild(resultDiv);

enterButton.addEventListener(“click”, function () {
const question = inputBox.value;
askChatGPT(question);
});

function askChatGPT(question) {
resultDiv.innerHTML = “Asking ChatGPT…”; // Display a loading message while waiting for the response

// Make a request to the OpenAI API to get a response from ChatGPT using the ‘davinci’ model
fetch(‘The engine i used but its a link so i cant post it’, {
method: ‘POST’,
headers: {
‘Content-Type’: ‘application/json’,
‘Authorization’: Bearer ${apiKey}
},
body: JSON.stringify({
prompt: question,
max_tokens: 50 // Adjust the max_tokens as needed
})
})
.then(response => response.json())
.then(data => {
console.log(‘API Response:’, data); // Log the response data

if (data.choices && data.choices.length > 0) {
  const answer = data.choices[0].text;
  resultDiv.innerHTML = `ChatGPT Response: ${answer}`;
} else {
  resultDiv.innerHTML = "ChatGPT did not provide a response.";
}

})
.catch(error => {
console.error(“Error:”, error);
resultDiv.innerHTML = “An error occurred while asking ChatGPT.”;
});
}

  1. The API is not free. You can go over to “billing overview” in your account and see your prepay credit balance.
  2. You shouldn’t trust an AI to write API code. It will do obsolete things like say “using the davinci” model" - and an obsolete “engine” URL I’m sure you have omitted there.

Instead, head over to the API reference on the forum sidebar, and read about “chat” and sending messages to the API. gpt-3.5-turbo will give an experience similar to free ChatGPT - but you must also maintain a conversation history unless you just have single standalone questions for the AI.