×Running Claude Code on a cheaper stack of models

Running Claude Code on a cheaper stack of models

A local LiteLLM proxy where a strong planner hands bounded coding jobs to cheap executors, with spend tracked per session.

Plain claude runs on my Claude subscription and I leave it alone. Next to it there’s local-code, which starts Claude Code pointed at a LiteLLM proxy on my Mac. The proxy maps the model names Claude Code asks for onto a different stack:

Role Model Cost
Main loop, the planner GLM-5.2 (Z.ai) about $0.14 per million tokens, blended
Heavy executor, model: sonnet DeepSeek V4 Pro pay per token
Mechanical executor, model: haiku Qwen3-Coder-30B in LM Studio free, it runs locally
Escalation, /model opus Anthropic Sonnet 5 pay per token

Why split planning from coding

DeepSeek is the best cheap coder I’ve found, around 80 on SWE-bench Verified, but a weak planner: 59 on agentic tasks against GLM’s 77. So GLM runs the loop and makes the decisions, and DeepSeek and Qwen do the typing.

Claude Code already has the hooks for this. Subagents ask for sonnet or haiku, and the proxy routes those names to the executors. Two subagent definitions do the delegating:

  • deepseek-coder writes code from a clear spec: a new module, a defined refactor, a well-scoped implementation. It isn’t for open-ended debugging or exploration, where it’s weaker.
  • qwen-grunt does mechanical work for nothing: precise edits across files, renames, formatting, running tests and builds and reporting the output.

The launcher adds a delegation policy that tells the planner to push execution down by default. The planner writes a bounded brief, an executor does it, and the planner checks the result.

The silent fallback

LM Studio loads Qwen with an 8,192-token context by default. Claude Code’s requests are bigger than that, the channel errors, and the proxy quietly falls back to DeepSeek. Everything still works and you save nothing. Load the model with a 65,536-token context instead:

lms load qwen/qwen3-coder-30b --context-length 65536 --gpu max

Cost per session

Claude Code stamps every request with its session id in Anthropic’s metadata.user_id. A LiteLLM callback reads it and writes each call’s model, tokens and cost to a local SQLite file, so spend breaks down by Claude Code session, not only by day. A small dashboard on port 4040 shows cost by session and by model, and usage.sh prints the same summary in a terminal. The same callback file does the routing and pins the response language.

What it’s for

The hybrid stack is for long, mechanical sessions where a frontier model on every turn is overkill: refactors with a clear spec, test-fixing loops, bulk edits. When a session needs real judgement, /model opus puts Anthropic’s Sonnet 5 on the loop through the same proxy, and the spend still lands in the same per-session table.

All writing