my-free-code README

The project's README from github.com/hkqr/my-free-code. As one markdown file: README.md.

My Free Code v0.8

A multi-provider gateway for Claude Code and other coding agents.

It is an independent implementation. It is not affiliated with Anthropic.

What v0.8 includes

Gateway protocols

Agent features

Provider layer

The catalog contains the broad provider set used by the project:

NVIDIA NIM, OpenRouter, Groq, OpenAI, xAI, QwenCloud, Together, DeepInfra, SiliconFlow, Nebius, Chutes, Featherless, ZenMux, W&B Inference, Azure OpenAI, Google AI Studio, Google Vertex, DeepSeek, Mistral, Codestral, OpenCode Zen, OpenCode Go, Vercel AI Gateway, Amazon Bedrock, Hugging Face, Cohere, GitHub Models, Wafer, Kimi, Kimi Code, MiniMax, Cerebras, SambaNova, Kilo, Fireworks, Novita, Cloudflare Workers AI, Z.ai, TokenRouter, NaraRoute, Poolside, LLM7, Ollama Cloud, LM Studio, llama.cpp and Ollama.

Provider entries are not fake claims of universal support: providers with unusual authentication/protocols require a dedicated adapter. The common OpenAI-compatible providers use the shared transport.

Coding-agent launcher layer

The architecture has launcher adapters for:

A launcher simply prepares the local proxy environment and delegates arguments to the installed client.

Architecture

             Coding Agents / IDEs
                      |
          +-----------+-----------+
          |                       |
    Anthropic Messages       OpenAI Responses
          |                       |
          +-----------+-----------+
                      |
                FastAPI Gateway
                      |
                Model Router
                      |
          +-----------+-----------+
          |                       |
       Primary                  Fallbacks
          |                       |
          +-----------+-----------+
                      |
              Provider Runtime
                      |
       +--------------+--------------+
       |              |              |
 OpenAI-compatible  Specialized   Local
     adapter          adapter     runtime
       |              |              |
     APIs          provider API  Ollama/LM Studio

The architecture deliberately separates wire protocols from routing and provider code. This mirrors the important architectural boundary in the current reference project: HTTP adapters, application routing/execution, provider runtime, CLI adapters and optional messaging are separate concerns. citeturn0search0

Install

Python 3.10+.

python -m venv .venv

Windows:

.venv\Scripts\Activate.ps1
python -m pip install -r requirements.txt
copy .env.example .env

macOS/Linux:

source .venv/bin/activate
python -m pip install -r requirements.txt
cp .env.example .env

Start:

python -m my_free_code

Default address:

http://127.0.0.1:8082

Configure a model

Example:

MODEL=open_router/openrouter/free
MODEL_SONNET=deepseek/deepseek-chat
MODEL_HAIKU=groq/llama-3.3-70b-versatile
MODEL_OPUS=nvidia_nim/meta/llama-3.3-70b-instruct
FALLBACK_MODELS=deepseek/deepseek-chat,ollama/llama3.1

Then set the corresponding API keys in .env.

The public model identity stays as the gateway model even when a request is routed to another upstream provider.

Claude Code

$env:ANTHROPIC_BASE_URL="http://127.0.0.1:8082"
$env:ANTHROPIC_AUTH_TOKEN="local"
$env:CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY="1"
claude

Or:

python -m my_free_code.cli.mfc claude

Other clients

The launcher abstraction supports:

python -m my_free_code.cli.mfc codex
python -m my_free_code.cli.mfc pi
python -m my_free_code.cli.mfc opencode
python -m my_free_code.cli.mfc cline
python -m my_free_code.cli.mfc hermes
python -m my_free_code.cli.mfc deepseek-harness
python -m my_free_code.cli.mfc grok
python -m my_free_code.cli.mfc muse

The installed client must already exist on PATH.

Routing and fallback

For:

MODEL_SONNET=deepseek/deepseek-chat
FALLBACK_MODELS=groq/llama-3.3-70b-versatile,ollama/llama3.1

a Sonnet request follows:

Claude Code
    |
    v
deepseek/deepseek-chat
    |
    | failure before output
    v
groq/llama-3.3-70b-versatile
    |
    | failure before output
    v
ollama/llama3.1

Once a streaming response has committed output, the gateway does not silently switch providers and duplicate the turn.

Reasoning

The gateway accepts Claude-style thinking intent and keeps it separate from provider-specific request translation.

Supported normalized modes:

auto
on
off

and optional effort:

low
medium
high

Provider adapters can map the normalized reasoning policy to their documented upstream fields.

Admin

Open:

http://127.0.0.1:8082/admin

Authenticated JSON endpoints:

GET /api/admin/status
GET /api/admin/models
GET /api/admin/providers

Local models

Ollama:

OLLAMA_BASE_URL=http://127.0.0.1:11434/v1
MODEL=ollama/llama3.1

LM Studio:

LM_STUDIO_BASE_URL=http://127.0.0.1:1234/v1
MODEL=lmstudio/qwen3.5-coder

llama.cpp:

LLAMACPP_BASE_URL=http://127.0.0.1:8080/v1
MODEL=llamacpp/my-model

Security

This is intended for local use.

Tests

pytest -q

The repository includes deterministic tests for routing, protocol conversion, auth, reasoning, model catalog and streaming primitives.

Project structure

my-free-code/
├── my_free_code/
│   ├── api/
│   │   ├── routes.py
│   │   └── admin_routes.py
│   ├── cli/
│   │   ├── claude.py
│   │   ├── launchers.py
│   │   └── mfc.py
│   ├── core/
│   │   ├── anthropic.py
│   │   ├── responses.py
│   │   ├── reasoning.py
│   │   ├── failures.py
│   │   ├── streaming.py
│   │   └── model_catalog.py
│   └── providers/
│       ├── catalog.py
│       ├── adapters.py
│       ├── specialized.py
│       └── runtime.py
├── tests/
├── ARCHITECTURE.md
├── .env.example
├── requirements.txt
├── pyproject.toml
└── README.md

License

MIT.

my-free-code (hkqr/my-free-code)

llm-gateway
Searching Database…

What is this?My Free Code is an open-source gateway that sits between coding agents like Claude Code and dozens of LLM providers, handling model routing, streaming, tool calls, reasoning pass-through and fallback between providers.
Is this a library I import, or a server I run locally?It is a standalone local server you run yourself, exposing Anthropic Messages and OpenAI Responses-compatible HTTP endpoints plus a local Admin UI, not a library you import into code.
How do I get it running?Install Python 3.10+, then run the included start script for Windows or macOS/Linux; it starts the proxy on a local default address that you then point your coding agent at.
Do I need API keys for every provider in the catalog?No, only for the providers you actually want to route to — you add those keys to your .env file, and the catalog ranges from cloud providers like OpenAI and OpenRouter to local runtimes like Ollama and llama.cpp.
Will it silently switch providers if one fails mid-response?No. Fallback only kicks in before a response has started streaming; once output has committed, the gateway will not switch providers and duplicate the turn.
Is it safe to expose this to the internet?No, it's built for local use only — bind the host to 127.0.0.1, set a real auth token, and never expose the Admin endpoints directly to the internet.
Which coding agents can I launch through this gateway?Launcher adapters exist for Claude Code, Codex, Pi, OpenCode, Cline, Hermes, DeepSeek Harness, Grok Build and Muse Code; each launcher just preps the local proxy environment and delegates to the already-installed client.
Can I run fully local models instead of cloud providers?Yes — Ollama, LM Studio and llama.cpp are supported as providers, so you can route requests to locally hosted models alongside or instead of cloud ones.
Does it support Claude's reasoning/thinking mode?Yes, it accepts Claude-style thinking intent, normalizes it into shared reasoning modes with an optional effort level, and provider adapters map that to each upstream's own thinking fields.
Do my provider credentials ever leak to other providers?No — credentials stay in your local environment/configuration per provider and are never forwarded to another provider.
Creator
hkqr
Size
0.7 MB
Stars
624
Updated
CommitOct 15
Age
1mo
Commits · 90 Days