HTTP status code: 429 (Too Many Requests) #28
-
Hi, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Isn't there a way to avoid making a fatal error, to delay and try again? |
Beta Was this translation helpful? Give feedback.
-
Hi Nicolas, The "Too Many Requests" error comes from the OpenAI API, not the Tectalic client. It means your application is hitting the rate limits set by OpenAI. One way to handle this is by implementing a retry strategy. For example, you could catch the Here is an example of how to do it: try {
// your code here
} catch (Tectalic\OpenAi\ClientException $e) {
if ($e->getCode() == 429) {
// sleep for a few seconds
sleep(5);
// retry the request
} else {
throw $e; // rethrow the exception if it's not a 429 error
}
} This simple approach may not be suitable for every application, especially for those making many requests. You might want to look into more sophisticated rate limiting or backoff strategies for those cases. I hope this helps! Csaba |
Beta Was this translation helpful? Give feedback.
Hi Nicolas,
The "Too Many Requests" error comes from the OpenAI API, not the Tectalic client. It means your application is hitting the rate limits set by OpenAI.
One way to handle this is by implementing a retry strategy. For example, you could catch the
Tectalic\OpenAi\ClientException
when the status code is 429, then pause for a few seconds and retry the request.Here is an example of how to do it:
This simple appr…