agentic icon indicating copy to clipboard operation
agentic copied to clipboard

Running into 429 errors on 4.2.0 as well as 4.1.0

Open karam-khanna opened this issue 2 years ago • 11 comments

Verify latest release

  • [X] I verified that the issue exists in the latest chatgpt release

Verify webapp is working

  • [X] I verify that the ChatGPT webapp is working properly for this account.

Environment details

v4.2.0 as well as v4.1.0

Describe the Bug

Running into following very frequently.

"error": {
    "message": "The server had an error while processing your request. Sorry about that!",
    "type": "server_error",
    "param": null,
    "code": null
  }
}

//

ChatGPTError: ChatGPT error 429: {
  "error": {
    "message": "The server had an error while processing your request. Sorry about that!",
    "type": "server_error",
    "param": null,
    "code": null
  }
}

    at file:///Users/karamkhanna/Documents/dev/dev-projects/StudyBuddy/node_modules/chatgpt/build/index.js:202:29
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  statusCode: 429,
  statusText: 'Too Many Requests',
  [cause]: Response {
    [Symbol(realm)]: null,
    [Symbol(state)]: {
      aborted: false,
      rangeRequested: false,
      timingAllowPassed: true,
      requestIncludesCredentials: true,
      type: 'default',
      status: 429,
      timingInfo: [Object],
      cacheState: '',
      statusText: 'Too Many Requests',
      headersList: [HeadersList],
      urlList: [Array],
      body: [Object]
    },
    [Symbol(headers)]: HeadersList {
      [Symbol(headers map)]: [Map],
      [Symbol(headers map sorted)]: null
    }
  }
}

I'm pretty confused by this since this should just be calling text-davinci, and I have a paid account set up so not sure why I'd be rate limited.

karam-khanna avatar Feb 09 '23 03:02 karam-khanna

I also encountered the same problem

Bclound avatar Feb 09 '23 05:02 Bclound

I know that paid accounts only have a limit of about 2x.

melodysdreamj avatar Feb 09 '23 07:02 melodysdreamj

I also encountered the same problem

chaos-zhu avatar Feb 09 '23 08:02 chaos-zhu

I also encountered the same problem

ikechan8370 avatar Feb 09 '23 08:02 ikechan8370

It came about by accident

chaos-zhu avatar Feb 09 '23 08:02 chaos-zhu

For me, I use a little retry mechanism because of this intermittent behavior:

export async function tryTimes(promiseFn, maxTries=10) {
    try {
        return await promiseFn();
    } catch (e) {
        if (maxTries > 0) {
            console.log("Failed, retry "+maxTries)
            return tryTimes(promiseFn, maxTries - 1);
        }
        throw e;
    }
}

and then call as follows:

let res = await tryTimes(async () => await api.sendMessage(question));

SimonBaars avatar Feb 09 '23 13:02 SimonBaars

@SimonBaars Thanks. For the time being will add something like that

karam-khanna avatar Feb 09 '23 16:02 karam-khanna

Frequently also now getting:

Error message: TypeError: fetch failed"

karam-khanna avatar Feb 09 '23 17:02 karam-khanna

This package is now using the official OpenAI API under the hood. I've seen occasional 429 errors as well which is either an OpenAI rate limit or problems on their end that we can't do anything about. I recommend that you write your app logic with this in mind.

https://github.com/sindresorhus/p-retry is also very useful

transitive-bullshit avatar Feb 14 '23 07:02 transitive-bullshit

I now have a ChatGPT Plus account but it doesn't solve this kind of problem. I guess ChatGPT Plus doesn't give more possibilities for the OpenAI API.

christophebe avatar Feb 17 '23 13:02 christophebe

I've tried getting this work using the API key I setup under the account. I have ChatGPT Plus, however, I don't think that has an impact on the API Key itself.

I even tried @SimonBaars nice retry suggestion and put it to 50 tries and they all fail with 429.

Do I need to add billing to the account for the API, or should it just work?

adam91holt avatar Feb 17 '23 14:02 adam91holt

@adam91holt the official OpenAI API has rate limits: https://platform.openai.com/docs/guides/rate-limits/overview

This is the official OpenAI API, so any consistent 429 errors you may be hitting are very likely because you're trying to use the API too aggressively.

If you're hitting 429 errors consistently, make sure you're adding some delay between your requests. Don't just retry 50 times in a row – that will make the problem worse and OpenAI may block your account. Use a smart retry method with exponential backoff like https://github.com/sindresorhus/p-retry

Your rate limits will go up quite a bit by adding payment to your account (though they'll still be limited by OpenAI for the first 48 hours to prevent abuse). See their official rate limits for more details.

Also note that I just added a new approach in v4.5.0 ChatGPTUnofficialProxyAPI which is free, though it is still rate limited.

transitive-bullshit avatar Feb 19 '23 08:02 transitive-bullshit