One idea
Your AI route is not done when it works once. It is done when it fails safely, retries only when useful, and tells the user what happened.
The main failures to plan for are rate limits, overloaded service, too much input, and too much output.
Know the errors
A 429 means you sent too many requests or tokens in a short time, or you hit a project, organization, credit, spend, or usage limit. Do not spam retries.
A 503 server_is_overloaded means the requested model temporarily lacks capacity. Wait, retry a few times, then show a useful message.