mnlaptev
mnlaptev

Reputation: 121

Are there any ways to improve handling of the insufficient_quota error while using spring-ai?

I am following the OpenAI Chat tutorial from Spring AI: https://docs.spring.io/spring-ai/reference/api/clients/openai-chat.html#_sample_controller_auto_configuration

As soon as I started the service, I noticed the following errors in the service log, while my requests seemed "hanging".

org.springframework.ai.retry.NonTransientAiException: 429 - {
    "error": {
        "message": "You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.",
        "type": "insufficient_quota",
        "param": null,
        "code": "insufficient_quota"
    }
}

The above is an expected outcome since I don't have $$$ on the account.

BUT, I wonder are there better ways to handle the insufficient_quota error from the other ones? As an example, I want to fail fast if there is such an error and keep retrying with default policies for any other errors.

Or, do I need to use my custom RetryTemplate in this case?

BTW, I've tried to set the following property, but it seems it doesn't take any effect...

spring.ai.retry.exclude-on-http-codes=429

Upvotes: 0

Views: 377

Answers (1)

I faced a similar challenge while working on a project,Handle the insufficient_quota, by visiting the OpenAI https://platform.openai.com/settings/organization/billing/overview and update the billing details.

Upvotes: 0

Related Questions