Free Claude Code Mix — Roteador de Modelos com Anthropic Nativo
Ianfr13/free-claude-code-mix
Roteador inteligente Opus→Anthropic, Sonnet/Haiku→DeepSeek com OAuth
Ver no GitHubAgent que estende o free-claude-code adicionando suporte nativo à API Anthropic, roteando requisições Opus para sua subscrição Claude Max (via OAuth), enquanto delega Sonnet/Haiku a provedores mais baratos (DeepSeek). Inclui persistência via systemd e correção do schema de thinking para compatibilidade total com a API real.
Instalação
npx convez-ai Ianfr13/free-claude-code-mix1 comando no terminal: detecta o formato do repositório (marketplace ou plugin avulso) e instala via Claude Code. Requer Node 18+ e o Claude Code instalado.
Métricas
Casos de uso
- Otimizar custos servindo Opus genuíno para tarefas premium e alternativas econômicas para modelos menores
- Manter compatibilidade total com Claude Code client forward de headers originais
- Persistência de múltiplas instâncias de proxy via systemd com isolamento de configuração
Veredito

Solução técnica robusta e pragmática para quem precisa balancear custos em produção sem sacrificar qualidade do modelo Opus. A correção do schema de thinking e o suporte idempotente de patches elevam o padrão, mas exige conforto com systemd e gestão de OAuth.
README
A tradução para o português deste README ainda está na fila.
free-claude-code · native-Anthropic-passthrough patch
Adds a native anthropic provider to free-claude-code so a tier (typically opus) is served by the genuine Anthropic API using the local Claude Max subscription OAuth token, while other tiers go to cheaper providers (DeepSeek).
Result, on the mix instance:
| Incoming tier | Routes to |
|---|---|
opus (claude-opus-4-8) | Anthropic real — your Claude Max subscription (OAuth bearer from ~/.claude/.credentials.json), with the genuine Claude Code client headers forwarded so it looks like the official client |
sonnet | deepseek-v4-pro (official DeepSeek API) |
haiku | deepseek-v4-flash (official DeepSeek API) |
Why a patch?
free-claude-code is a tier-router proxy but ships no anthropic provider (its purpose is to replace Anthropic). It's installed as a uv tool, so edits to its site-packages are wiped by uv tool upgrade. This repo restores the change idempotently.
Contents
anthropic_native/ New provider (subclass of AnthropicMessagesTransport)
├── client.py Headers (OAuth bearer + forwarded client headers) + thinking-schema fix
├── client_headers.py Per-request capture of the real Claude Code headers (contextvar)
└── oauth.py Reads + refreshes the subscription OAuth token
apply.py Idempotently copies the provider + re-applies 3 core edits
systemd/fcc@.service systemd template unit (one instance per config dir)
env-templates/ Sanitized .env examples (NO secrets)
install.sh apply.py + install/enable systemd services
Core edits applied by apply.py
config/provider_catalog.py— adds theanthropicdescriptor (basehttps://api.anthropic.com/v1).providers/registry.py— registers the_create_anthropicfactory.api/routes.py— captures incoming client headers so the provider can replay them upstream.
Key gotcha (the thinking-schema fix)
Opus 4.8 sends thinking: {type: "adaptive"}. The shared free-claude-code body builder rewrote it to {type: "enabled"} without budget_tokens, which the genuine API rejects (thinking.enabled.budget_tokens: Field required). The provider's _build_request_body override normalizes thinking to the real schema (adaptive → {type:"adaptive"} with no extra keys; enabled → requires budget_tokens) and passes everything else (tools, system, context_management, output_config, metadata, signed thinking blocks) through untouched.
Install
sudo ./install.sh # runs apply.py + installs/enables systemd services
Or manually:
python3 apply.py # patch site-packages
cp systemd/fcc@.service /etc/systemd/system/
systemctl daemon-reload
systemctl enable --now fcc@free-claude-code-mix # etc. per config
Each instance is driven by FCC_ENV_FILE=/root/.config/<name>/.env (see env-templates/).
Ports: free-claude-code→8082, …-gpt→8083, …-flash→8084, …-mix→8086.
Point Claude Code at an instance with ANTHROPIC_BASE_URL=http://localhost:8086.
Caveats
- Secrets (
DEEPSEEK_API_KEY,OPENROUTER_API_KEY, the OAuth credentials) are not in this repo — only sanitized templates. - OAuth refresh: the token (~hours) auto-refreshes via the stored refresh token; the refresh endpoint/client-id are the public Claude Code values.
- ToS: routing a Claude Max subscription through a proxy with spoofed official-client headers is a gray area of Anthropic's terms; the risk is on the subscription account.