OC-201b · Module 2

The Tiered Fallback Pattern

3 min read

Not every request needs the most expensive API. The tiered fallback pattern routes each request to the cheapest provider that can fulfill it, escalating to more expensive tiers only when cheaper ones fail or lack the required capability. This is the same pattern CLAWMANDER teaches in OC-201a for Twitter search — FXTwitter (free) to twitterapi.io (cheap) to X API v2 (expensive) to Grok (fallback). The pattern applies to any domain where multiple providers offer overlapping capability at different price points.

The architecture has three components. A capability registry that maps each provider to the request types it can handle. A cost-ordered provider list that tries the cheapest first. And a fallback chain that catches failures at each tier and promotes to the next. The business logic calls a single function — "get this data" — and the tiered system figures out the cheapest way to fulfill it. Your module never knows which tier actually served the request. It gets the same normalized response regardless of which provider answered.

  1. 1. Catalog Provider Capabilities For each API domain, list every provider with its capabilities, cost per call, rate limits, and reliability. Some providers handle only simple lookups. Others handle complex queries. Map the coverage so you know which requests can go to the cheap tier and which require the premium tier.
  2. 2. Order by Cost Sort providers from cheapest to most expensive. Free tiers first, then pay-per-call, then subscription tiers. The fallback chain always tries in this order. You only pay premium prices when cheaper options genuinely cannot fulfill the request.
  3. 3. Implement the Fallback Chain Each provider attempt catches failures and promotes to the next tier. Log which tier served each request so you can analyze cost distribution over time. If the cheapest tier handles 80% of requests, your average cost per call is far below the premium rate.