How I Cut AI Costs with a Hybrid LLM Pipeline
I was using Claude Opus to generate boilerplate and reformat JSON, and the bill looked like I was paying a senior architect to paint walls. The output was fine. The problem was that most of those tokens never needed a model that good.
Most teams I talk to do the same thing: pick one model and use it for everything. It's the easy default, and it's expensive. The fix was to stop treating AI work as one kind of task.
Two kinds of work
I split tasks into reasoning and execution. Reasoning is architecture decisions, requirement analysis, edge-case hunting and code review. Execution is code from a clear spec, test scaffolding, documentation and formatting.
Reasoning goes to Claude Opus. Execution goes to a cheaper model like GLM-4-Flash or Claude Haiku. Execution is where the volume is. I assumed a per-token price gap of 10-20x, which varies with the model and with input versus output pricing, and I haven't pinned it to specific model versions. On the tasks I tried, the cheaper model's output was good enough when the spec was precise, but that is an observation, not a controlled comparison. Correctness-sensitive code still has to pass the checks below.
The pipeline
- Opus: spec~2,000 tokens
- Cheap model: implement~15,000 tokens
- Opus: review~1,000 tokens
- Cheap model: fix flagged sectionsonly what failed
If the review finds problems, only the flagged sections get regenerated, not the whole feature. I ask the review model to check for security issues, architectural violations and subtle bugs. I don't have evaluation evidence about what a cheaper model is more or less likely to miss, so the review is a set of checks I ask for, not a measured safety net. A model review doesn't prove the code works, so the implementation and every fix must pass the relevant tests and checks. Any finding that is still unresolved goes back through review and verification instead of ending at regeneration.
Where the savings come from
The token split on a typical feature is what matters. The token counts in the flow are generated tokens. About 3,000 generated tokens (spec plus review) come from Opus, and about 15,000 from the cheap model. The chart below prices only those output tokens, in Opus-token equivalents. It leaves out the input side: in the review step, Opus also has to read the spec and the implementation, and that input volume would raise the Opus share and shrink the saving.
Counting only generated tokens, Opus for everything costs 18,000 units. The hybrid costs 4,500 units if the cheap model is 10x cheaper and 3,750 if it is 20x cheaper, roughly 75-79% less. Input tokens are not included.
| Label | Value (Opus-token equivalents) |
|---|---|
| Opus for everything | 18000 |
| Hybrid, cheap model 10x cheaper | 4500 |
| Hybrid, cheap model 20x cheaper | 3750 |
This chart is my back-of-envelope arithmetic, not a benchmark or a measured before/after, and it is an output-token-only illustration, not a full feature-cost estimate. It treats all tokens as one price, ignores the difference between input and output pricing, and doesn't count input context, retries or fix passes, which push the real number down. I don't have a spend comparison on a matched workload, so treat roughly 75% as an upper-end estimate for this token mix, not a measured result.
What it cost me and what I got
I've run this for six months across several projects. The cost is extra plumbing: you need automated handoffs between phases and a structured spec format, and a review that is allowed to reject work.
In return I get a lower bill and no manual copying between steps. I haven't measured throughput, so I won't put a multiplier on it. I don't have absolute costs to share either, so whether this pays off for you depends on your workload and budget.
Cite this article
Mohamed Hosny, “How I Cut AI Costs with a Hybrid LLM Pipeline”, www.mohamed-hosny.dev, . https://www.mohamed-hosny.dev/blog/hybrid-llm-cost-optimization
Referencing this? Please credit Mohamed Hosny and link to the original page.