Giving Claude Code Subagents Different Backends: Routing Cheap Work to Cheap Models on One Key
Learn how to assign different model backends to Claude Code subagents so that cheap, well-scoped tasks like search, summarization, and linting run on DeepSeek, Qwen, or GLM, while critical reasoning stays on Claude. This guide covers routing logic, verification, and the economics of using a single API key across multiple models.
Why route subagents to different models
Claude Code subagents are specialized assistants that handle subtasks within a larger workflow. By default, they all use the same backend model. But not every subtask needs the same level of capability. Search, summarization, and linting are largely pattern-matching and transformation tasks that cheaper models can handle well. Keeping them on Claude wastes budget. Routing them to DeepSeek, Qwen, or GLM reduces cost without sacrificing quality on the tasks that matter.
Which subtasks are safe for cheap models
The key is to match task complexity to model capability. Here are common subtasks and a general guideline:
- Search and retrieval: Finding files, grepping for patterns, extracting snippets. These are deterministic and low-risk. DeepSeek or Qwen can handle them.
- Summarization: Condensing logs, diffs, or documentation. Qwen and GLM are strong at summarization and translation.
- Linting and formatting: Checking style, flagging obvious issues. DeepSeek and GLM are sufficient.
- Simple refactoring: Renaming variables, extracting constants. Qwen or DeepSeek can do this reliably.
- Code generation with clear specs: Writing boilerplate from a template. GLM or Qwen work well.
- Complex reasoning: Architecture decisions, debugging subtle bugs, security reviews. Keep these on Claude.
- Multi-step planning: Breaking down ambiguous requirements. Claude's strength.
- Final review and validation: Ensuring correctness and consistency. Claude.
A useful heuristic: if the subtask can be described precisely and its output is easy to verify, a cheaper model is likely fine. If the subtask requires judgment, creativity, or deep context, use Claude.
How to assign models per subagent
Claude Code allows you to define subagents with their own configuration. While the exact mechanism depends on your setup, the general approach is to specify a model identifier when defining the subagent. With a multi-model API aggregator, you use the same API key and endpoint, but change the model name in the request.
For example, a subagent definition might include a model field:
{
"name": "search-helper",
"model": "deepseek-chat",
"instructions": "Search the codebase for relevant files and return snippets."
}
And another for critical tasks:
{
"name": "architect",
"model": "claude-3-opus",
"instructions": "Design the module structure and review for scalability."
}
When using an aggregator, you point the base URL to the aggregator's endpoint and use the same API key for all subagents. The aggregator routes each request to the specified model.
Verifying that routing actually happened
It's easy to assume routing works, but you should verify. Here are practical checks:
- Check response metadata: Many aggregators return the model name in the response headers or body. Log it and assert it matches the expected model.
- Compare token usage and cost: Cheap models have different pricing. If costs per call are consistently lower for certain subagents, routing is likely working.
- Inspect latency: Different models have different latencies. A sudden spike or drop can indicate misrouting.
- Use distinctive prompts: Craft a prompt that only the intended model would answer in a specific way (e.g., a model-specific quirk). This is less reliable but can catch gross errors.
- Audit logs: Most aggregators provide request logs. Filter by subagent or model to confirm distribution.
- Test with a canary: Route a small percentage of traffic to a known model and verify the response matches expectations.
Set up automated checks in your CI pipeline to catch misrouting early.
Keeping one key while using many models
A multi-model aggregator lets you use a single API key for all models. This simplifies key management and billing. You top up with USDC on Base (no KYC), and the aggregator handles routing. You pay the official price times 1.3 for usage. If you contribute keys to the aggregator, you get credited official price times 1.1 (or 1.2 for premium models) in USDC.
This model is transparent: you see the official price and the multiplier. There's no hidden markup beyond the stated factor. For teams, this means you can experiment with different models without managing multiple accounts or payment methods.
Best practices and pitfalls
- Start conservative: Route only low-risk subtasks to cheap models. Expand as you gain confidence.
- Monitor quality: Cheap models may produce subtly wrong outputs. Always validate critical results with Claude or human review.
- Handle failures gracefully: If a cheap model fails or times out, fall back to Claude.
- Watch context windows: Some models have smaller context windows. Ensure your prompts fit.
- Document your routing: Keep a mapping of subagents to models and the rationale.
- Avoid over-optimization: The goal is cost efficiency, not squeezing every penny. Keep critical paths on Claude.
Conclusion
Routing subagents to different backends is a practical way to reduce costs without sacrificing quality. By assigning search, summarization, and linting to DeepSeek, Qwen, or GLM, and keeping complex reasoning on Claude, you get the best of both worlds. With a single API key from an aggregator, you can implement this easily and verify it works. Remember to pay attention to the cost multiplier: you pay 1.3x official price, and contributors get 1.1x back. This is a straightforward trade-off for convenience and flexibility.