Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ERROR] Error: ChatGPTAPI error 429 #111

Closed
lfunderburk opened this issue Dec 12, 2022 · 20 comments
Closed

[ERROR] Error: ChatGPTAPI error 429 #111

lfunderburk opened this issue Dec 12, 2022 · 20 comments

Comments

@lfunderburk
Copy link

Hello,

Was able to install and use it for simple requests, but when it takes a bit to formulate a response I get the error

[ERROR] Error: ChatGPTAPI error 429

@saltcute
Copy link

My experiment showed that OpenAI now cuts your connection once it has been made for about 60s, and every request after that would return error 429. You need to reset (i.e. get a new) conversation.

@transitive-bullshit
Copy link
Owner

Hmmm, yes I'm seeing this randomly as well.

Though my twitter bot seems to be chugging along just fine. It's been running for the last few hours now without any 429s or other errors. So it could be account or IP-related as well.

We'll be investigating more in the coming days.. please post if you figure anything out.

@tedjames
Copy link

Experiencing this as well on my end :/

@alex12058
Copy link

I got this eror when I provided a conversationId but not a parentMessageId to the sendMessage function. I found including the parentMessageId fixed this.

@solserer-labs
Copy link

This was also happening for me using the GPT frontend for me when it had to return long code snippets.

@ThomasAlbrt
Copy link

I got this eror when I provided a conversationId but not a parentMessageId to the sendMessage function. I found including the parentMessageId fixed this.

You've saved my sanity sir.

@chadsarrouf
Copy link

Same thing here, still no solution! @transitive-bullshit is this a known issue?

The first request seems to work fine, but as soon as I send the second message in a conversation I get this error. I wasn't running into this problem a few a days ago. I've tried waiting between messages a few minutes, but it doesn't seem to fix anything.

@MarvynSTAR
Copy link

Same thing here, still no solution! @transitive-bullshit is this a known issue?

The first request seems to work fine, but as soon as I send the second message in a conversation I get this error. I wasn't running into this problem a few a days ago. I've tried waiting between messages a few minutes, but it doesn't seem to fix anything.

Maybe it's a limit of time for each answer to be completed that has been set by OpenAI, because the error (to me) only occurs when the answer is taking time (~more than a minute) to be concluded.
Given this, I’m not sure there’s a solution to this problem on our side.

@chadsarrouf
Copy link

chadsarrouf commented Dec 14, 2022

Same thing here, still no solution! @transitive-bullshit is this a known issue?
The first request seems to work fine, but as soon as I send the second message in a conversation I get this error. I wasn't running into this problem a few a days ago. I've tried waiting between messages a few minutes, but it doesn't seem to fix anything.

Maybe it's a limit of time for each answer to be completed that has been set by OpenAI, because the error (to me) only occurs when the answer is taking time (~more than a minute) to be concluded. Given this, I’m not sure there’s a solution to this problem on our side.

Hmm interesting. I seem to be getting the error immediately upon sending my second request, so it doesn't seem to be a time limit issue for me.

I am still able to make requests on the openai chatgpt playground, and starting new conversations seems to work with chatgpt-api too for the first message, but as soon as I send my second message I get blocked with 429

@MarvynSTAR
Copy link

MarvynSTAR commented Dec 14, 2022

Same thing here, still no solution! @transitive-bullshit is this a known issue?
The first request seems to work fine, but as soon as I send the second message in a conversation I get this error. I wasn't running into this problem a few a days ago. I've tried waiting between messages a few minutes, but it doesn't seem to fix anything.

Maybe it's a limit of time for each answer to be completed that has been set by OpenAI, because the error (to me) only occurs when the answer is taking time (~more than a minute) to be concluded. Given this, I’m not sure there’s a solution to this problem on our side.

Hmm interesting. I seem to be getting the error immediately upon sending my second request, so it doesn't seem to be a time limit issue for me.

Is your second request "complex" (requires a long reply) or the error occurs regardless of the question asked?
Personally just a few minutes ago I asked several questions to the AI through the library without incurring any error.

I've just seen the edit to the comment. Maybe I'm not understanding well, but are you using AI from the site and library at the same time with the same account? @chadsarrouf

@transitive-bullshit
Copy link
Owner

I'm seeing this as well. It seems to be happening pretty randomly, and once an account starts 429'ing, there's not much you can do to escape it.

Will continue investigating.

@transitive-bullshit
Copy link
Owner

To be clear, this is not something that this package can fix easily. It is intentional on the part of OpenAI and/or Cloudflare, and we just need to try and reverse-engineer what is going on and circumvent it.

Super frustrating, but until the official API comes out, these sorts of issues will unfortunately take place.

@chadsarrouf
Copy link

chadsarrouf commented Dec 14, 2022

Same thing here, still no solution! @transitive-bullshit is this a known issue?
The first request seems to work fine, but as soon as I send the second message in a conversation I get this error. I wasn't running into this problem a few a days ago. I've tried waiting between messages a few minutes, but it doesn't seem to fix anything.

Maybe it's a limit of time for each answer to be completed that has been set by OpenAI, because the error (to me) only occurs when the answer is taking time (~more than a minute) to be concluded. Given this, I’m not sure there’s a solution to this problem on our side.

Hmm interesting. I seem to be getting the error immediately upon sending my second request, so it doesn't seem to be a time limit issue for me.

Is your second request "complex" (requires a long reply) or the error occurs regardless of the question asked? Personally just a few minutes ago I asked several questions to the AI through the library without incurring any error.

I've just seen the edit to the comment. Maybe I'm not understanding well, but are you using AI from the site and library at the same time with the same account? @chadsarrouf

Right thanks for pointing that out! I had some tabs open, I made sure to close all instances of the site and tried running the request again through the library, but alas same issue! 429 message after one message. I will try to send two messages not part of a conversation see what that yields.

Update: I tried testing multiple single api messages vs conversation messages, same result, 429 after first request

@chadsarrouf
Copy link

chadsarrouf commented Dec 14, 2022

I'm seeing this as well. It seems to be happening pretty randomly, and once an account starts 429'ing, there's not much you can do to escape it.

Will continue investigating.

To be clear, this is not something that this package can fix easily. It is intentional on the part of OpenAI and/or Cloudflare, and we just need to try and reverse-engineer what is going on and circumvent it.

Super frustrating, but until the official API comes out, these sorts of issues will unfortunately take place.

@transitive-bullshit Yea that is understandable, will report back with any findings I come across. Built a really cool chose-your-own-adventure-app using your library just want to get it working again :)

@MarvynSTAR
Copy link

Same thing here, still no solution! @transitive-bullshit is this a known issue?
The first request seems to work fine, but as soon as I send the second message in a conversation I get this error. I wasn't running into this problem a few a days ago. I've tried waiting between messages a few minutes, but it doesn't seem to fix anything.

Maybe it's a limit of time for each answer to be completed that has been set by OpenAI, because the error (to me) only occurs when the answer is taking time (~more than a minute) to be concluded. Given this, I’m not sure there’s a solution to this problem on our side.

Hmm interesting. I seem to be getting the error immediately upon sending my second request, so it doesn't seem to be a time limit issue for me.

Is your second request "complex" (requires a long reply) or the error occurs regardless of the question asked? Personally just a few minutes ago I asked several questions to the AI through the library without incurring any error.
I've just seen the edit to the comment. Maybe I'm not understanding well, but are you using AI from the site and library at the same time with the same account? @chadsarrouf

Right thanks for pointing that out! I had some tabs open, I made sure to close all instances of the site and tried running the request again through the library, but alas same issue! 429 message after one message. I will try to send two messages not part of a conversation see what that yields.

Oh ok! Keep us updated, any information can be useful to solve this problem.

To add my personal experience to @transitive-bullshit’s statement, I struggle to find a scheme for the "appearance" of the errors 429. A few minutes ago I've encountered one and now, even by changing conversation, they continue to occur. Instead before after finding one I just had to change conversation to solve everything and be able to ask other questions.
It's worth mentioning that if with the same account and IP I manually go to the site of the AI, everything works fine and I can ask questions without any error appearing.

@tedjames
Copy link

tedjames commented Dec 15, 2022

I'm now getting ONLY 429 responses :(

Everything seems to be implemented as expected. I'm able to get valid tokens and log into my account for them manually. My app was even working fine all day morning.

When I called getConversation(), I am seeing that the conversationID and message ID are undefined. Not sure if that's an issue or not...

@transitive-bullshit
Copy link
Owner

This should be significantly improved using the new fully-browser-based solution available in https://github.com/transitive-bullshit/chatgpt-api/releases/tag/v2.4.0

@transitive-bullshit
Copy link
Owner

https://github.com/transitive-bullshit/chatgpt-api/releases/tag/v2.4.0 introduces a now fully browser-based solution, ChatGPTAPIBrowser that should resolve a lot of people's 403 / 429 errors — unless your account of IP address has been banned.

Please give the new version a try and let me know how it goes in a new issue.

Thanks, and sorry for all the headaches that Cloudflare has caused.

@alex12058
Copy link

alex12058 commented Dec 16, 2022

This is my current setup to initialise the api. I'm using the old solution because I'm using onConversationResponse to stream the message as it is generated through a websocket to my frontend.

// Load the api (declared as a const at the top of the file)
const initApi = (async () => {
	// Use puppeteer to bypass cloudflare (headful because of captchas)
	const openAIAuth = await getOpenAIAuth({
		browser: await getBrowser({ executablePath: "/usr/bin/chromium" }),
		email: process.env.OPENAI_EMAIL,
		password: process.env.OPENAI_PASSWORD,
	});

	return new ChatGPTAPI({ ...openAIAuth });
})();


// Usage (within a function within a websocket server)

// Wait for the api to init
const api = awiat initAPi;

// Check if the tokens are still valid
try {
	await api.ensureAuth();
}
catch (e) {
	console.log(e);
	return ws.send(JSON.stringify({ error: e.toString() }));
}

// Send a message through the api and stream the response to the websocket client
await api.sendMessage(
	message,
	{
		conversationId,
		parentMessageId,
		timeoutMs,
		onConversationResponse: response => {
			// Stream response to client
		},
	}
);,

When I do my first request without a conversationId or parentMessageId it works. However, when I send the next message in the conversation with the conversationId and parentMessageId I get this error. This happens even if I wait some random amount of time between 1 and 20 second before sending the next message.

{
  statusCode: 429,
  statusText: 'Too Many Requests',
  response: 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
    }
  }
}

Edit: The ChatGPTAPIBrowser solution works for me and I no longer get 429 errors. Though in order to use this I had to manually edit the .js file so defaultChromeExecutablePath() would return the path to my chromium. The path issue is fixed by #152.

@sinhaab
Copy link

sinhaab commented Feb 1, 2023

Hello,

Was able to install and use it for simple requests, but when it takes a bit to formulate a response I get the error

[ERROR] Error: ChatGPTAPI error 429

I was facing the same issue. I used new email address and password and it worked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants