Guide

How AI agents should handle API failures

Errors, empty answers and wrong answers: how an agent can tell them apart, when to retry, when to switch provider, and how not to pay for failures.

An agent should treat an API failure as one of three things: an error (retry once), an empty answer (try another provider), or a wrong answer (check before using it). The costly mistake is treating all three as success, or paying for them.

Three kinds of failure

Kinds of API failure and what to do
KindExampleWhat to do
Error or timeoutHTTP 500, or no answer in 30 secondsRetry once, then switch
Empty answerNo email found, zero search resultsTry the next provider
Wrong answerA catch-all email marked valid, a captcha page instead of contentCheck the result against a rule before using it

Retry rules that work

Check before you use it

The failures that hurt most aren't errors. They're answers that look fine: an email that bounces, a page that's really a block screen. Write the check down as a rule, and run it on every result.

How Arettic handles it

Every rule is on Pass rules, and every error code on Error codes.

Questions

Should an agent retry a failed API call?

Once, after an error or a timeout. After that, switch provider or stop. Never retry an error that says the input is invalid.

Do I pay for failed calls on Arettic?

No. A call the provider fails costs nothing, and a guaranteed job that fails its check is refunded.

Updated 2026-10-23 · This page as Markdown · JSON

Give your agent every tool on one key.

Get your free API key