I am getting an error while making an essay web app

so i was making a essay app i am getting this error

POST https://api.openai.com/v1/completions 429

This is my code

<!DOCTYPE html>
  <title>Essay Generator</title>
<body style="background-color: crimson;">
  <h1 style="text-align: center;">Essay Generator</h1>
  <form style="background-color: aqua; text-align: center; border-color: rgb(16, 30, 221); border-radius: 10cm;">
    <label for="topic">Topic:</label><br>
    <input type="text" id="topic" name="topic"><br>
    <label for="wordCount">Word Count:</label><br>
    <input type="number" id="wordCount" name="wordCount"><br><br>
    <button type="button" onclick="sendTopicAndWordCount()">Generate Essay</button>
  <div id="response" style="text-align: center;"></div>

    function sendTopicAndWordCount() {
      // Get the topic and word count from the form
      var topic = document.getElementById("topic").value;
      var wordCount = document.getElementById("wordCount").value;

      // Make the API request using a CORS proxy
      fetch("https://api.openai.com/v1/completions", {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          "Authorization": "Bearer key"
        body: JSON.stringify({
          "model": "text-davinci-003",
          "prompt": "essay on" + topic,
         "max_tokens": wordCount,
          "temperature": 0.1
      .then(response => response.json())
      .then(response => {
        // Display the API's response in the div
        document.getElementById("response").innerHTML = response.text;
      // https://cors-anywhere.herokuapp.com/https://api.openai.com/v1/completions

Welcome to the community!

Are you able to access via the command line or Playground?

A 429 server error means too many requests / throttling…

But I am only requesting 50 word essay

Where in the code are you calling sendTopicAndWordCount()? Are you requesting it multiple times maybe?

Can you try with a different model to see if it’s the same error?

what do you mean ? and i have tried different more but still same error

I have been trying to solve this error for almost a week. :smiling_face_with_tear:

Where are you adding this? Just in the HTML?

Oh, I see you have the form in your HTML too.

I’m sorry, but I’ve run out of ideas. You might need to hit up chat support…


Good luck!

1 Like

I have already sent them a message. Thanks for trying. No one is able to help me till now.

1 Like

after around how much time does chat support reply?

This should help. You can’t just post to the URL, I believe… And you need to safely send your API key…


I changed my api and now i am getting this error POST https://api.openai.com/v1/completions 400

i fixed the error but i am not getting any response now just undefined