convez.ai
PluginAutomaçãoAvançado
scott-tan-ai

CC-TPR — Roteador de Planos de Token para Claude Code

scott-tan-ai/CC-TPR

Roteamento inteligente de modelos para maximizar uso e minimizar custo

Ver no GitHub
InicialPluginScore · de 0 a 100

Plugin que otimiza o uso do Claude Code através de roteamento inteligente entre múltiplos modelos (MiniMax M3, Z.AI GLM-5.1, DeepSeek V4 Pro) baseado na janela de contexto. Permite 10x mais uso mantendo qualidade e reduzindo custos em comparação com Claude Pro. Suporta 15 provedores diferentes e roteamento automático quando contexto se aproxima do limite.

Instalação

$npx convez-ai scott-tan-ai/CC-TPR

1 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

Estrelas
2
Forks
0
Acompanhando
0
Saúde
42%
Último commit
há 5 meses
Versão
v2.0.5
Issues abertas
0
Contribuidores
1

Casos de uso

  • Otimização de custos para desenvolvimento contínuo com Claude Code
  • Roteamento automático entre modelos frontier quando contexto se aproxima do limite
  • Aproveitar benchmarks superiores de MiniMax M3 e Z.AI GLM-5.1 com economia

Veredito

Solução sólida e técnica para quem usa Claude Code profissionalmente e quer otimizar custos reais. A abordagem de multi-provider com roteamento por contexto é pragmática, mas requer manutenção das credenciais de múltiplos serviços e acompanhamento de preços flutuantes no mercado de modelos.

README

A tradução para o português deste README ainda está na fila.

CC-TPR v2 — Claude Code Token Plan Router

Make Claude Code Work 10x More, Nonstop, Same Intelligence.

This router lets Claude Code use MiniMax M3 (frontier coding, 1M context, native multimodality) and Z.AI GLM-5.1 (ties/beats Opus 4.6 on hardest coding benchmarks) -- while automatically routing to DeepSeek V4 Pro (1M context) when your context approaches the threshold.


What's new in v2.0.1

v2.0.1 is a ground-up restructure of v1.5.5:

  1. Model-centric config -- each Claude model (haiku/sonnet/opus) has its own complete routing block.
  2. Provider registry -- adding a new provider is 1 file + 1 config block.
  3. OpenAI format support -- Cerebras and other OpenAI-format providers work natively.
  4. Per-model context windows -- 114 models across all 15 providers in MODEL_CONTEXT_LIMITS.
  5. 8 new providers -- Together AI, OpenAI, Alibaba, Tencent, Infini, Baidu, China Telecom, Microsoft Foundry.
  6. Anthropic passthrough -- set provider: anthropic to route directly to Claude's real API.

Real cost breakdown (no hidden maths)

PlanMonthly costNotes
Claude Pro (Sonnet + Opus)$20Low usage ceiling
MiniMax Starter (M2.7)$101,500 requests / 5h
Z.AI Lite (GLM-5.1)$18~80 prompts / 5h
Subtotal (replaces Claude Pro)$28Does 10x more work and costs $8 more than Claude Pro
DeepSeek V4 Pro (1M context)$0/month + initial $2 min.Pay as you use -- typical <$2/month

Updated June 2026: MiniMax M3 is now available. The Plus plan at $20/month gives you 1.7B tokens/month of M3 usage (replaces the $10 Starter). This brings the monthly total to $38 ($20 MiniMax Plus + $18 Z.AI) OR $40 if you choose to go with Anthropic ($20 MiniMax Plus + $20 Claude Pro). M3 beats Sonnet 4.6 on SWE-bench and adds 1M context, native multimodality, and MSA sparse attention.


Real-time status line (what you see while using Claude Code)

CC-TPR status line showing routed model and context window CC-TPR status line showing routed model and context window

left to right: directory | actual active model | context window | 5hr quota & reset countdown | weekly quota & reset countdown


Why this router exists

Claude Pro charges $20/month for barely enough usage to build anything substantial.

ModelSWE-bench VerifiedSWE-bench ProAPI cost (per 1M output)
Claude Sonnet 4.655%--~$15.00
MiniMax M3--59.0%~$1.20 (12.5x cheaper)
MiniMax M2.778%--~$1.20 (12.5x cheaper)
Claude Opus 4.6--57.3%~$25.00
Z.AI GLM-5.1--58.4% (top spot)~$3.10 (8x cheaper)

The router gives you the best of both worlds -- M3 for daily coding, GLM-5.1 for hard planning, plus a 1M-token emergency brake via DeepSeek when context exceeds the threshold.


Referral links -- how you keep this project alive

We don't charge for the router. The only way we afford to maintain it is through referral commissions when you sign up for the required plans.

You pay exactly the same price -- no markup, no fake bonuses. We get a small commission that pays for development. If everyone signs up directly, this project dies. If you find value in CC-TPR, please use the links below.

PlanDirect link (supports us)
MiniMax Token Plan (M3, M2.7)https://platform.minimax.io/subscribe/token-plan?code=VaYpkbSg4M
Z.AI GLM Token Plan (GLM-5.1)https://z.ai/subscribe?ic=ER6MB4WO5C

Already subscribed? You can still help by giving our github repo a star


Why M3 over Sonnet? (MiniMax)

MetricM3Sonnet 4.6Real-world impact
SWE-bench Pro59.0%--Surpasses GPT-5.5 and Gemini 3.1 Pro
Terminal-Bench 2.166.0%--Reliable autonomous execution
Context window1M tokens200K5x more context via MSA sparse attention
MultimodalNative (image + video)Image onlyUnderstands screenshots, diagrams, UI
API cost (per 1M output)~$1.20~$15.0012.5x cheaper

MiniMax Token Plan Plus ($20/month) gives you ~1.7B tokens/month of M3 usage -- enough for full-time daily coding.

Get MiniMax via our referral link


Why GLM-5.1 over Opus? (Z.AI)

MetricGLM-5.1Opus 4.6Winner
SWE-bench Pro58.4% (top spot)57.3%GLM
Terminal-Bench 2.069.065.4GLM
AIME 2026 (math)95.3~88%GLM
GPQA (science)86.291.3Opus (rarely used)
Max autonomous steps1,200+--GLM

Conclusion: For 94.6% of coding tasks, GLM-5.1 is indistinguishable from Opus -- and it actually leads on the hardest engineering benchmark.

The GLM Coding Lite ($18) gives ~3x the prompts of Claude Pro.

Get Z.AI GLM via our referral link


How the context fallback works (DeepSeek V4 Pro)

  • M3 supports up to 1M tokens (MSA sparse attention). M2.7 and GLM both have a 200K token context window.
  • When your conversation reaches the configured threshold, the router pre-emptively switches to DeepSeek V4 Pro (1M context).
  • DeepSeek is pay-as-you-go -- you make a minimum first-time payment of $2 to unlock the model. After that, you add credits as needed (no monthly fee).
  • Most users spend less than $2/month on DeepSeek, because large contexts are rare.

Supported providers

Core providers (recommended)

#ProviderFormatPlanNotes
1MiniMaxAnthropic$10-120/mo Token PlanM3, M2.7
2Z.AIAnthropicGLM Coding PlanGLM-5.1
3DeepSeekAnthropicPay-per-tokenV4 Pro (1M context)
4OpenRouterAnthropicPay-per-tokenSlug-transformed failover

Also supported

#ProviderFormatPlanNotes
5CerebrasOpenAIPay-per-tokengpt-oss-120b
6Xiaomi MiMoAnthropicPay-per-tokenmimo-v2.5-pro
7Moonshot KimiAnthropicPay-per-tokenkimi-k2.6
8Together AIOpenAI$25 free creditsMiniMax, qwen3-coder
9OpenAIOpenAIPay-per-tokengpt-5.x
10Alibaba CloudAnthropic$50/mo Proqwen3.5-plus
11Tencent CloudAnthropic¥40-200/moHunyuan
12InfiniAnthropic¥40-200/mokimi-k2.5, glm-5
13Baidu QianfanAnthropicMultiple tiersERNIE-5.0
14China TelecomAnthropic¥29-699/moGLM-5
15Microsoft FoundryAnthropicAzure EnterpriseReal Claude 4.x
16AnthropicAnthropicClaude Pro/MaxDirect passthrough

Quick start

Windows

  1. Clone the repo
  2. Double-click CC-TPR_Win_Start.bat -- a CMD window opens with the router running.
  3. Start Claude Code as usual -- it will automatically route through the proxy.
  4. Close the CMD window or press Ctrl+C when done. Or run stop-router_Win.bat.

macOS / Linux

  1. Clone the repo
  2. Make scripts executable (first time only):
    chmod +x CC-TPR_Mac_Start.sh stop-router_Mac.sh
    
  3. Run the launcher:
    ./CC-TPR_Mac_Start.sh
    
  4. Start Claude Code as usual -- it will automatically route through the proxy.
  5. Stop the router: press Ctrl+C or run ./stop-router_Mac.sh from another terminal.

Note: Closing the terminal window on macOS stops the router automatically. No lingering processes.


Manual Status Line (Zed, Terminal, cmd, PowerShell)

CC-TPR status line showing routed model and context window

For editors without statusLine.command support (Zed, VS Code), CC-TPR provides a standalone Python script that displays real-time routing status inline.

Running from Zed

  1. Open Zed to your CC-TPR project

  2. Toggle the terminal: press Ctrl+` (or `Cmd+`` on Mac)

  3. Run the status line:

    Windows:

    python statusline\manual_statusline_start.py
    

    macOS/Linux:

    python3 statusline/manual_statusline_start.py
    

Output format

myproject | MiniMax-M3 | [####....] 45% 210k | [##......] 3% 2h32m | [##......] 2% 5d05h
           model          context bar           5hr quota         weekly quota

Color coding

UsageColor
< 70%Green
70-79%Orange
>= 80%Red
WaitingDIM

Stopping

Press Ctrl+C in the terminal running the script.


Configuration

FilePurpose
config.yamlModel routing rules, context thresholds, server threads
.env (copy from .env.example)API keys

Core API keys

MINIMAX_API_KEY=your_key
ZAI_API_KEY=your_key
DEEPSEEK_API_KEY=your_key
OPENROUTER_API_KEY=your_key

Additional providers (optional)

CEREBRAS_API_KEY=
XIAOMI_API_KEY=
MOONSHOT_API_KEY=
TOGETHER_API_KEY=
OPENAI_API_KEY=
ALIBABA_API_KEY=
TENCENT_API_KEY=
INFINI_API_KEY=
BAIDU_API_KEY=
CTYUN_API_KEY=
AZURE_FOUNDRY_API_KEY=
ANTHROPIC_API_KEY=

See docs/ROUTING.md for the full config schema, and docs/ARCHITECTURE.md for how the router works internally.

Thread & Concurrency Settings

In config.yaml, server.threads controls how many concurrent requests the router handles:

server:
  threads: 3  # default: +3 per concurrent Claude Code session
Concurrent SessionsRecommended threads
13 (default)
26
3+9+

If you see WARNING:waitress.queue:Task queue depth is X (X >= 3 under normal load), increase threads in config.yaml to match your workload.

The router uses Waitress (production WSGI server) instead of Flask's dev server -- stable for overnight long-running tasks.


Migrating from v1.5.5

v2.0.1 has a breaking config schema. v1.5.5 stays as a tag for users who need it.

Manual migration steps:

  1. routing.models.<key> --> routing.<key>.provider
  2. providers.<name>.model --> routing.<key>.model (same value across keys using that provider)
  3. Global smart_switch + context_threshold --> per-key smart_switch
  4. Remove failover.final_fallback (if present) -- v2.0.1 chain ends at OpenRouter
  5. Remove providers.<name>.context_limit (if present) -- now lives in MODEL_CONTEXT_LIMITS map

Development

Windows

python -m venv .venv
.venv\Scripts\python.exe -m pip install -e ".[dev]"
pytest
pyright
python -m src.main

macOS / Linux

python3 -m venv .venv
.venv/bin/pip install -e ".[dev]"
pytest
pyright
.venv/bin/python -m src.main

License

MIT -- free for any use, including commercial.


FAQ

Q: Do I really need both plans? A: You could use only MiniMax (replaces Sonnet & Haiku) and skip GLM. But GLM is only $18 and gives Opus-class reasoning -- worth it for planning/architecture/review.

Q: What if I never hit the context threshold? A: Then you never pay DeepSeek beyond the initial $2 deposit. Your monthly stays at $28 (Starter) or $38 (M3 Plus).

Q: Why not just use OpenRouter directly? A: OpenRouter doesn't give you token-plan pricing. Our router uses monthly subscription plans (MiniMax, Z.AI) which are ~10x cheaper than pay-as-you-go API.

Q: What's new in v2.0.1? A: Model-centric config, provider registry, OpenAI format support, 114-model context window map, and 8 new providers. See the "What's new" section above.

Q: Do I need all 16 providers? A: No. Most users need 2-3: MiniMax + Z.AI + DeepSeek. The others are optional and only require API keys if you want to use them.

Q: Can I use a custom model? A: Yes. Edit config.yaml to point any routing key at any provider/model combo. You can also set provider: anthropic to pass requests directly to Anthropic's API without remapping.

Q: What if my provider isn't listed? A: If the provider supports the Anthropic Messages API format, you can add it by creating a provider entry in config.yaml. See docs/ARCHITECTURE.md for how providers work.

Ver o original no GitHub

Bom para

Relacionados