Who it is forA developer whose coding agent stalls when one hosted provider has an outage or rate limit during a long task.
The problemA single provider failure stops the session, and the developer has to change configuration by hand to continue.
The outcomeRequests fall through the configured FALLBACK_MODELS list when a provider fails before output, and the session keeps going.
What you need first
- Python 3.11 or newer
- A clone of the my-free-code repository
- At least one provider API key for the MODEL values you choose, or a local model server such as Ollama, LM Studio, or llama.cpp
- Claude Code or another supported client installed and on PATH
Steps
- Run
python -m venv .venv, thenpython -m pip install -r requirements.txt, thencp .env.example .envas described in the setup section of the README. - In .env, set MODEL_SONNET to your primary model and FALLBACK_MODELS to a comma-separated list such as groq/llama-3.3-70b-versatile,ollama/llama3.1.
- Add the API keys for each provider in the list to .env.
- Run
python -m my_free_codeand send a test request from Claude Code or another client. - Check the gateway output for a failover event before relying on the chain for real work.
Prompt for your agent
In the my-free-code repository, set MODEL_SONNET to <primary-model> and FALLBACK_MODELS to <fallback-model-1>,<fallback-model-2> in .env, then start the gateway with python -m my_free_code. Expected output: a test request completes using the primary model. Verify that the gateway falls through to the next model when the primary is made to fail before output.
Caveat. The README says fallback only applies before output is committed, so a stream that has already started will not switch providers.
Get 5 new use cases every morning. Free, one short email, unsubscribe anytime.
Get them freeShare: X LinkedIn Hacker News Email Copy link
Disclaimer
Deduped lists open-source repositories that belong to other people. We do not own, maintain, audit, or vouch for any of them, and a repo appearing here is not an endorsement or a safety check. The use cases, steps, and prompts are written by AI and may be incomplete, outdated, or just wrong. Where a use case is marked "Seen in the wild", we link to public posts where someone described something similar, but we have not verified those posts and the use case itself is still our AI's own write-up. Use all of this at your own risk. Only run code, commands, or agents on systems and accounts you are authorized to use, and read the code and every command before you run it, especially anything that touches credentials, files, or the network. Nothing here is professional, security, legal, or financial advice. All trademarks and project names belong to their respective owners, and their use here does not imply affiliation. Content is provided as is, without warranties of any kind. Found a mistake, a safety problem, or something you want removed? Email [email protected] and we will look at it promptly. Full disclaimer page