Skip to content

HTTP 429 not caught #259

@bilogic

Description

@bilogic

Describe the bug
Unable to catch exception when LLM API runs out of credit

==> storage/logs/laravel.log <==
[2025-08-13 08:51:12] production.ERROR: Client error: `POST https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent` resulted in a `429 Too Many Requests` response:
{
  "error": {
    "code": 429,
    "message": "You exceeded your current quota, please check your plan and billing deta (truncated...)
 {"exception":"[object] (GuzzleHttp\\Exception\\ClientException(code: 429): Client error: `POST https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent` resulted in a `429 Too Many Requests` response:
{
  \"error\": {
    \"code\": 429,
    \"message\": \"You exceeded your current quota, please check your plan and billing deta (truncated...)
 at /var/www/stage/vxcharts10/current/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:111)
[stacktrace]

To Reproduce
Steps to reproduce the behavior:

try {
    $agent = Agent::make()
        ->key(config('gpt.gemini.key'));
    $response = $agent->chat(new UserMessage($question));
    $text = (string) $response->getContent();
} catch (NeuronAI\Exceptions\NeuronException $e) {
    // catch all the exception generated just from the agent
} catch (NeuronAI\Exceptions\ProviderException $e) {
    // Fired from AI providers and embedding providers
    // expected out of credit exception here    
}

Expected behavior
Expected the exception to be caught at expected out of credit exception here

Screenshots
N/A

The Neuron AI version you are using:

  • 1.16.14

Additional context
N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions