hkqr/my-free-code

Open-source multi-provider AI gateway for Claude Code and other coding agents, with model routing, streaming, tools, reasoning, fallbacks, and local model support

What it solves

My Free Code is a multi-provider gateway that allows coding agents (like Claude Code, Cline, and others) to use a wide variety of LLM providers instead of being locked into a single API. It acts as a proxy that translates requests between different API protocols (such as Anthropic and OpenAI) and manages how requests are routed to the underlying models.

How it works

The project implements a FastAPI gateway that separates the wire protocols from the routing and provider logic. When a coding agent sends a request, the gateway receives it via an Anthropic or OpenAI-compatible endpoint, routes it through a model router, and then sends it to the a selected provider via a specialized adapter.

Key mechanisms include:

  • Protocol Translation: It supports Anthropic Messages and OpenAI Responses protocols to ensure compatibility with different agents.
  • Model Routing & Fallback: Users can configure primary models and a list of fallback models. If the primary provider fails before producing output, the gateway automatically switches to the next model in the sequence.
  • Provider Integration: It includes a broad catalog of providers, including cloud APIs (OpenRouter, Groq, DeepSeek) and local runtimes (Ollama, LM Studio, llama.cpp).
  • Launcher Adapters: It provides a CLI tool to easily launch supported coding agents with the correct environment variables and proxy settings.

Who it’s for

Developers and AI engineers who use coding agents but want the flexibility to use different LLM providers, local models, or implement automatic failover for reliability.

Highlights

  • Extensive Provider Support: Integrates with dozens of providers including NVIDIA NIM, OpenRouter, Groq, and local tools like Ollama.
  • Detailed Routing Control: Supports per-provider concurrency, rate-window control, and ordered model fallback.
  • Reasoning Pass-through: Handles Claude-style thinking/reasoning metadata and maps it to provider-specific fields.
  • Agent Launchers: Built-in support for launching agents like Claude Code, Codex, and Cline via a dedicated CLI.
  • Admin UI: Includes a local admin interface and authenticated API for monitoring status and providers.

Related

  • Project
  • Project
  • Project
  • Project