Credentials. Provider API keys are stored in the .env file, so keep .env out of commits and never share it.
Who it is forA developer who uses Claude Code daily and wants to try or pay for models from other providers when a session starts.
The problemClaude Code expects its own model backend, so switching providers normally means changing the agent or giving up its workflow.
The outcomeClaude Code runs against a local gateway address, and each Claude tier (Sonnet, Haiku, Opus) maps to the provider model you set in .env.
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, then activate it withsource .venv/bin/activateon macOS or Linux. - Run
python -m pip install -r requirements.txt. - Run
cp .env.example .env, then set MODEL, MODEL_SONNET, MODEL_HAIKU, and MODEL_OPUS plus the matching provider API keys in .env. - Run
python -m my_free_codein one terminal and keep it running at http://127.0.0.1:8082. - Run
python -m my_free_code.cli.mfc claudein a second terminal to start Claude Code through the gateway.
Prompt for your agent
Work in the my-free-code repository. Set MODEL_SONNET in .env to <provider/model-id>, start the gateway with python -m my_free_code, then launch Claude Code with python -m my_free_code.cli.mfc claude. Expected output: Claude Code opens and answers a short test prompt. Verify that the gateway log shows a request routed to <provider/model-id>.
Caveat. The project states it is an independent implementation and is not affiliated with Anthropic.
Use this in your AI agent
Ask your agent
Using the Deduped MCP, get the setup steps for hkqr/my-free-code and "Run Claude Code on other model providers"
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