claudefree: The Ghost API That Lets Claude Code Think It Still Talks to Anthropic

A fast Python gateway that fakes the Anthropic surface, discovers providers dynamically, and reroutes Claude Code to a moving target of alternative models.

7 to 9 min read • View on GitHub • More from Yashwanth-Kumar-26

A wide editorial scene shows a Claude Code terminal window entering a customs checkpoint labeled Anthropic, then slipping into a hidden corridor that splits into many provider doors. The image explains the core trick: the CLI sees a familiar handoff while the gateway quietly redirects traffic elsewhere.
The illusion is the product. Claude Code keeps its familiar handshake while the backend target changes behind the curtain.
Key Takeaways

The trick is not that Claude Code changes. It does not. `claudefree` makes the CLI believe it is still speaking to Anthropic, then intercepts the conversation and points it at a different model supply. That is why the project feels less like a chatbot and more like a stage illusion with good engineering underneath.

That illusion is the whole thesis. The repo preserves the premium feel of Claude Code, but strips away the dependency on a single vendor. For developers who care about the workflow more than the billing model, that is a compelling trade.

Why this matters: a premium CLI becomes a portable shell

Most tools in this space ask you to adopt a new interface. `claudefree` does the opposite. It keeps the interface people already know and shifts the burden onto a compatibility layer that speaks just enough Anthropic to satisfy the client.

Claude Code is just a client that talks to the Anthropic API format. You can redirect it to any LLM that speaks that format.

Prince Arora, Tech Blogger · How I Set Up Claude Code for Free
Tool pathInterface preservedProvider flexibilitySetup styleProxy required
claudefreeYes, Claude Code stays in placeHigh, through dynamic adaptersLightweight gateway plus configYes
Aider or ClineNo, you adopt a different toolHigh, but inside that toolDirect app setupNo
Cursor or OpenCodePartially, but within a new product surfaceMedium to highOpinionated environmentNo
Direct Claude Code with AnthropicYesLow, tied to AnthropicSimplest if you already payNo

Inside the gateway: four steps from request to streamed reply

The brain of the repo is `GatewayService`. Its job is simple to describe and tricky to execute: catch Claude-shaped requests, decide where they should go, translate them for the chosen provider, then stream the response back in Anthropic format.

The gateway does not do one big transformation. It does several smaller ones, each narrow enough to preserve the Claude Code contract.

The flow is practical rather than elegant. First comes interception, including shortcuts for trivial replies. Then model selection maps the Claude model name to a backend and upstream model. After that, local token estimation gives the gateway enough accounting to keep the stream coherent. Finally, the backend adapter emits SSE chunks that are rewritten into the shape Claude Code expects.

The real scaling trick: provider discovery is outsourced

One reason proxy projects go stale is obvious. Hardcode enough providers and the list becomes a maintenance burden the moment the ecosystem shifts. `claudefree` avoids that trap by pulling from a dynamic registry at `models.dev` and caching the result locally with a TTL.

That design is small but important. The repo does not need to own the universe of providers. It borrows a live catalog, stores a local copy for speed, and stays focused on the translation problem instead of becoming a directory of every model vendor on earth.

A WSJ-style hedcut portrait of the project creator based on the verified GitHub avatar. The face grounds the origin story in a real maintainer rather than an abstract repo, reinforcing that this compatibility layer is the work of a single developer.

Adapters do the translation work

The most interesting part after the gateway is the adapter factory. Instead of hand-curating a giant routing matrix, `claudefree` inspects provider metadata and chooses a speaking style. Anthropic-native providers get one adapter. OpenAI-compatible providers get another. The point is not classification for its own sake. It is choosing the minimum protocol bridge that keeps the stream alive.

A close-up workshop scene shows a Claude-shaped plug entering a socket while a switchboard inspects its markings. On the right, two adapter arms extend from a shared base, one stamped Anthropic-native and one OpenAI-compatible, with thin wires fanning toward upstream endpoints. The image explains how provider metadata becomes a routing decision.
The adapter layer is where the gateway stops pretending and starts translating. Classification determines the protocol bridge, which determines everything downstream.

That flexibility is the payoff. As new providers appear in the registry, the proxy can often support them with little or no bespoke code. The repo is not trying to outsmart the model ecosystem. It is trying to stay out of its way.

The messy part: streaming, usage, and token accounting

The hard part of a proxy is not returning a response. It is returning the right shape of response while the upstream is still talking. `claudefree` deals with that by translating live SSE chunks and using heuristics when providers expose usage data inconsistently.

That is the kind of compromise that separates a demo from a useful tool. Different vendors report output tokens differently, and some reveal them only after the fact. The repo answers with local estimation, chunk parsing, and enough bookkeeping to keep Claude Code satisfied without pretending the protocol mismatch does not exist.

A lightweight proxy that routes Claude Code's Anthropic API calls to NVIDIA NIM (40 req/min free), OpenRouter (hundreds of models), or LM Studio (fully local).

Rishurajgautam24, GitHub Project Maintainer · free-claude-code README

How it compares to other ways of escaping vendor lock-in

ProjectWhat it optimizes forWhat you give up
claudefreeClaude Code continuity with backend flexibilityA direct, native Anthropic connection
AiderTerminal-native pair programming across providersThe Claude Code interface itself
ClineAgentic coding inside VS CodeA separate proxy layer and CLI fidelity
CursorIntegrated product polishLess control over protocol-level swapping
OpenCodeOpen source coding agent breadthThe drop-in Claude Code illusion

That comparison is the real story. `claudefree` is not trying to be the best coding agent. It is trying to be the least disruptive way to keep using one.

What this repo is really testing

Small infrastructure projects often reveal bigger shifts before the flagship products do. `claudefree` suggests that in AI tooling, the valuable thing may not be the model endpoint. It may be the interface people have already learned, trusted, and built habits around.

That is a strong idea, even if the implementation is scrappy. Compatibility layers are usually invisible when they work. Here, the entire project is built to make that invisibility feel like a feature.