Back to Prompts
Coding Assistant

Configure a Provider Priority Chain

For building flexible multi-provider systems From the Smart Abstraction AI Coding Building Block.

Prompt
Help me build a configurable provider chain for [AI generation / scraping / payments / email].

Language: [Python, JavaScript, TypeScript, etc.]

I want to:
1. Define providers in a config (name, function, priority, cost)
2. Try them in priority order
3. Track which provider succeeded
4. Optionally skip expensive providers when cheaper ones work

Example providers:
- [List your providers, e.g., OpenAI, Claude, local model]
- [Or: BeautifulSoup, ScraperAPI, cached data]
- [Or: Stripe, PayPal, manual invoice]

Requirements:
1. Easy to add/remove providers without changing core logic
2. Each provider has a timeout (don't wait forever for a dead service)
3. Configurable retry count per provider
4. Log the full chain of attempts (for debugging)
5. Return which provider worked alongside the result

Make it production-ready but explain everything simply. I want to understand the pattern so I can extend it later.
1 views 0 copies