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.
Use this in your AI agent
Ask your agent
Using the Deduped MCP, get the setup steps for hkqr/my-free-code and "Keep agent sessions running when a provider fails"
Add Deduped to Claude Code once
claude mcp add --transport http deduped https://dedupedai.com/mcp
Every Monday: the 5 hottest repos and exactly how to use them. Free, one email a week, unsubscribe anytime.
Get them freeShare: X LinkedIn Hacker News Email Copy link
Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer