Skip to content

better error reports for chat fallbacks#2783

Merged
ProgrammerIn-wonderland merged 1 commit intoHeyPuter:mainfrom
P3il4:better-errors
Apr 8, 2026
Merged

better error reports for chat fallbacks#2783
ProgrammerIn-wonderland merged 1 commit intoHeyPuter:mainfrom
P3il4:better-errors

Conversation

@P3il4
Copy link
Copy Markdown
Contributor

@P3il4 P3il4 commented Apr 7, 2026

improves error reporting for .chat calls
currently if user sends something invalid like

await puter.ai.chat(
    [],
    { model: "google/gemini-2.5-flash-lite" }
);

we simply respond with

{"success":false,"error":"no fallback model available"}

which isn't really helpful
with this:

{
    "success": false,
    "error": {
        "attempts": [
            {
                "model": "gemini-2.5-flash-lite",
                "provider": "gemini",
                "error": "400 status code (no body)"
            },
            {
                "model": "openrouter:google/gemini-2.5-flash-lite",
                "provider": "openrouter",
                "error": "400 Input required: specify \"prompt\" or \"messages\""
            }
        ],
        "code": "ai_chat_all_providers_failed",
        "$": "heyputer:api/APIError",
        "message": "All AI chat providers failed (2 attempts)",
        "status": 502
    }
}

list all providers tried and what they reported. openrouter makes it clear what is wrong
or if something is wrong on our side, makes it easier to debug from user reports:

...
{
  "model": "openrouter:google/gemini-2.5-flash-lite",
  "provider": "openrouter",
  "error": "403 Key limit exceeded (total limit). Manage it using https://openrouter.ai/settings/keys"
}
...

@ProgrammerIn-wonderland ProgrammerIn-wonderland merged commit 32be3a0 into HeyPuter:main Apr 8, 2026
3 of 4 checks passed
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

Successfully merging this pull request may close these issues.

2 participants