A failed tool call is not just one wasted request. The agent appends the error to the conversation and re-sends the whole history, so every retry costs more tokens than the last. A long run that dies late returns nothing for all of it. Start at [fastaf.co](/).

## Answer first

*   Fail fast: set a timeout on each data call and a hard cap on attempts (2-3).
*   Retry only errors that can change: 429, 502, 503 and network timeouts. A 400, 402, 404 or 422 will come back the same.
*   Keep error traces short: pass the agent a one-line error, not the full response.
*   Use a data API that does not bill failures, so retries cost tokens only.

FastAF source timeouts and outages use `503` with `Retry-After: 5` and `{error: {code: "upstream_timeout" | "upstream_unavailable", message, stage: "upstream_fetch", retry_after: 5}}`, not a billable result. Reserved credits on `/v1` are refunded; x402 does not settle. See [source outages](/docs/#upstream-outage).

## What FastAF does

*   With x402, failed calls are not charged: the payment is verified before the call and settled only when FastAF answers 200. Source errors, empty results, blocks and invalid input are not settled.
*   FastAF already retries a transient failure once on its side for search routes (Google, Bing, news, shopping and the other structured searches), inside the same paid call. Keep your own retries few.
*   The 402 price quote comes back before any payment: on 28 October 2026, eight unpaid requests got it in 61-308 ms.
*   Fixed prices per call (Google search $0.003). Retries do not add to the bill, because only an attempt answered with 200 is settled: the worst case is calls x price. See the [x402 price list](/pricing/x402-price-list/).

## Pattern

```
import time
import requests

URL = "https://api.fastaf.co/x402/v1/serp"
RETRY_ON = {429, 502, 503}  # temporary; 400, 402, 404, 422 will not change on a retry


def search(query, session=None, attempts=3):
    """Return (data, None) or (None, one-line error for the agent)."""
    http = session or requests.Session()
    error = "search failed: not attempted"
    for attempt in range(attempts):
        wait = 2 ** attempt  # 1 s, then 2 s
        try:
            r = http.get(URL, params={"query": query}, timeout=20)
        except requests.RequestException as exc:
            error = f"search failed: {type(exc).__name__}"
        else:
            if r.status_code == 200:
                return r.json(), None
            error = f"search failed: HTTP {r.status_code}"
            if r.status_code not in RETRY_ON:
                break
            if r.headers.get("Retry-After", "").isdigit():
                wait = int(r.headers["Retry-After"])
        if attempt + 1 < attempts:
            time.sleep(wait)
    return None, error


data, error = search("mcp registry")
print(error or data)
```

Run as is, with a plain `requests.Session`, it stops at the first attempt with `search failed: HTTP 402`: nothing pays the quote. To pay, pass a session wrapped by an x402 client, for example `wrapRequestsWithPayment(requests.Session(), client)` from the x402 Python package (`pip install "x402[clients,evm]"`) with an EVM signer registered for Base. The client signs the 402 quote and retries the same request; FastAF settles only if that request returns 200. For a complete client in JavaScript (`@x402/fetch` with a wallet key), see the [x402 example in the docs](/docs/#x402).

A client timeout is not a FastAF failure: FastAF decides on settlement from its own answer, not from whether your client is still waiting. Keep the timeout above the normal latency of the route you call.

Related: [heavy pages and timeouts](/how-to/heavy-pages-timeouts/), [fallback search provider](/how-to/search-api-fallback-provider/), [agent spend caps](/how-to/agent-spend-caps-per-call-pricing/).

Try it: 500 free credits every month after email verification, or x402 with no account.

Source of the advice: builders on X, October 2026 (retry storms in agent loops).

## Reference

*   [x402 documentation](/docs/#x402): every parameter and response field
*   [Docs](/docs/): authentication, errors, MCP and [x402](/docs/#x402)
*   [Pricing](/pricing/): credit packs from $10, without expiry

## Other sources

*   [How to read public Amazon data when your requests fail](/how-to/read-amazon-data/)
*   [How to read public Google Search data when your requests fail](/how-to/read-google-data/)
*   [How to read public Walmart data when your requests fail](/how-to/read-walmart-data/)
*   [How to read LinkedIn data with an API](/how-to/read-linkedin-data/)
*   [How to read public eBay data when your requests fail](/how-to/read-ebay-data/)
*   [How to read public Booking.com data when your requests fail](/how-to/read-booking-data/)
*   [How to read X profile data with an API](/how-to/read-x-data/)
*   [How to read public Zillow data when your requests fail](/how-to/read-zillow-data/)
*   [Pay-per-call web scraping for AI agents with x402](/how-to/x402-pay-per-call-web-scraping/)
*   [MCP servers for Amazon, SERP and web scraping](/how-to/best-mcp-servers-amazon-serp-scraping/)
*   [Cost per agent: monthly SaaS vs x402 pay-per-call](/how-to/cost-per-agent-saas-vs-x402/)
*   [How FastAF handles heavy pages and timeouts](/how-to/heavy-pages-timeouts/)
*   [x402 endpoint discovery checklist: how agents find a paid API (and how FastAF passes it)](/how-to/x402-discovery-checklist/)
*   [Add FastAF to Claude Code, Codex and Cursor](/how-to/add-fastaf-claude-code-codex-cursor/)
*   [How to detect poisoned or incomplete SERP results in AI agents](/how-to/detect-poisoned-incomplete-serp-results/)
*   [Cap agent spend per call with fixed x402 prices](/how-to/agent-spend-caps-per-call-pricing/)
*   [Use FastAF from the Cloudflare Agents SDK](/how-to/fastaf-cloudflare-agents-sdk/)
*   [FastAF as a fallback search provider](/how-to/search-api-fallback-provider/)
*   [Budget a scraping job before you run it](/how-to/budget-scraping-job-fixed-prices/)
*   [Try FastAF for free, no card](/how-to/free-search-api-for-agents/)
*   [Too many MCP tools? Keep agent context small](/how-to/mcp-tool-schema-bloat/)
*   [How agents find an API (and where FastAF is)](/how-to/agent-discovery-files/)
*   [All how-to guides](/how-to/)

## Compare

*   [FastAF vs SerpApi](/compare/serpapi/)
*   [FastAF vs Exa](/compare/exa/)
*   [FastAF vs Tavily](/compare/tavily/)
*   [FastAF vs Firecrawl](/compare/firecrawl/)
*   [FastAF vs Apify](/compare/apify/)
*   [FastAF vs toll402](/compare/toll402/)
*   [FastAF vs serp402](/compare/serp402/)
*   [FastAF vs AgentBIT](/compare/agentbit/)
*   [FastAF vs Amazon PA-API](/compare/amazon-pa-api/)
*   [FastAF vs Serper](/compare/serper/)
*   [FastAF vs ScrapingBee](/compare/scrapingbee/)
*   [FastAF vs ScraperAPI](/vs/scraperapi/)
*   [FastAF vs Bright Data](/vs/bright-data/)
*   [Benchmarks](/benchmarks/): latency and cost per 1,000 requests, measured

## Try it on your own request

500 free credits every month after email verification, no card.

[Start free](/signup/)[x402 documentation](/docs/#x402)

## Related

*   [How to read public Amazon data when your requests fail](/how-to/read-amazon-data/)
*   [How to read public Google Search data when your requests fail](/how-to/read-google-data/)
*   [How to read public Walmart data when your requests fail](/how-to/read-walmart-data/)
