Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

HTTP status code: 429 (Too Many Requests) #28

Answered by the-csaba
absoluteweb asked this question in Q&A
Discussion options

You must be logged in to vote

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:

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 appr…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@absoluteweb
Comment options

Answer selected by the-csaba
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants