OpenAI dont support certain countries or is my code wrong?

Does it mean that i cant use OpenAI API beeacuse i live in kosovo and it looks that OpenAI doesnt support its API services in certain countries. Or is just my code wrong? (Error 429)

type or paste code hereconst chatInput = document.querySelector(".chat-input textarea");
const sendChatBtn = document.querySelector(".chat-input span");
const chatBox = document.querySelector(".chatbox");

let userMessage;
const API_KEY = "MY_API_KEY";

const createChatLi = (message, className) => {
    const chatLi = document.createElement("li")
    chatLi.classList.add("chat", className);
    let chatContent = className === "outgoing" ? `<p>${message}</p>` : `<span class="material-symbols-outlined">smart_toy</span><p>${message}</p>`;
    chatLi.innerHTML = chatContent;
    return chatLi    
}

const generateResponse = (incomingChatLi) => {
  const API_URL =  "https://api.openai.com/v1/chat/completions"
  const messageElement = incomingChatLi.querySelector("p")

  const requestOptions = {
    method: "POST",
    headers: {
        "Content-Type": "application/json",
        "Authorization": `Bearer ${API_KEY}`
    },
    body: JSON.stringify({
        model: "gpt-3.5-turbo",
        messages: [{role: "user", content: userMessage}]
    })
  }
  fetch(API_URL, requestOptions).then(res => res.json()).then(data =>{
    messageElement.textContent = data.choices[0].message.content
  }).catch((error) =>{
    messageElement.textContent = "Oops! Something weent wrong. Please try again"
  })
}

const handleChat = () => {
     userMessage = chatInput.value.trim();
     if(!userMessage) return;
Q
     chatBox.appendChild(createChatLi(userMessage, "outgoing"));

     setTimeout(() => {
        const incomingChatLi = createChatLi("Thinking...", "incoming")
        chatBox.appendChild(incomingChatLi);
        generateResponse(incomingChatLi)
     }, 600)
}
sendChatBtn.addEventListener("click", handleChat);

Hi and welcome to the Developer Forum!

Kosovo is not currently a supported country, so that is the main issue, the 429 error is a rate limit message, but I’m unsure if that is down to the country or if you are making too many API calls in a short space of time / lack of a payment method being added to your account.

Should i put a payment method then maybe it will work? Im checking my api usage and its 0$?

You can certainly give it a try, I’m not sure what the results will be though.

Yes i put 5$ into my account and now its working it seems that the complimentary 18$ were expired
and now its working . Thank you very much for helping me :slight_smile: <3