You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Routing Smart: A Data-Driven Approach to Choosing Between DeepSeek V3, Qwen3, and GLM-4 for Production Workloads
#13
When building applications on top of multiple Chinese LLM APIs, one of the most common architectural questions is: should you route requests to different models based on task type, or just pick one and stick with it?
After running production workloads across DeepSeek V3, Qwen3, and GLM-4 for several months, I want to share some concrete data and a routing pattern that cut our API costs by ~40% without sacrificing output quality.
The Setup
We tested three models across five task categories:
Task Type
Prompt Avg Tokens
Samples
Code generation
850
200
Code review / fix
1,200
200
Summarization
2,500
200
Creative writing
600
200
Multi-turn reasoning
3,800
200
Key Findings
1. Code Generation: DeepSeek V3 dominates
DeepSeek V3 produced functionally correct code at the highest rate in our tests (~87% pass rate on HumanEval-style tasks), but more importantly, its deepseek-coder variant was significantly cheaper for code-specific workloads:
fromaiwaveimportAIWaveclient=AIWave(api_key="your-key")
# Cost-optimized routing for code tasksresponse=client.chat.completions.create(
model="deepseek-coder", # Best $/quality ratio for codemessages=[
{"role": "system", "content": "You are a senior Python engineer."},
{"role": "user", "content": "Write a production-ready retry decorator with exponential backoff."}
],
temperature=0.1, # Low temp = fewer hallucinated APIsmax_tokens=2000,
)
print(f"Tokens used: {response.usage.total_tokens}")
print(f"Estimated cost: ${response.usage.total_tokens*0.14/1_000_000:.6f}")
For reference, GLM-4 scored ~79% on the same benchmark at a similar price point, while Qwen3 landed at ~82% but with noticeably more verbose outputs (increasing cost per request).
This was the surprise. In multi-turn conversations exceeding 10+ rounds, GLM-4 maintained instruction adherence significantly better than the other two. We measured "instruction drift" — how often the model started ignoring or misinterpreting earlier constraints:
DeepSeek V3: drift in ~18% of long conversations after turn 8
Qwen3: drift in ~22% of long conversations
GLM-4: drift in only ~9% of long conversations
If you're building agents or multi-step reasoning pipelines, GLM-4 is worth the slightly higher per-token cost.
3. Summarization: All three are within margin of error
For document summarization (2K-5K token inputs), all three models produced qualitatively similar summaries as rated by human evaluators. The differentiator was speed, not quality:
In our tests, DeepSeek V3 consistently streamed fastest (~65-80 tok/s), Qwen3 was mid-pack (~40-55 tok/s), and GLM-4 was slowest but most stable (~35-45 tok/s with lower variance).
The Routing Strategy
Based on this data, here's the cost-aware routing logic we implemented:
fromaiwaveimportAIWavefromenumimportEnumclassTaskType(Enum):
CODE_GEN="code_gen"CODE_REVIEW="code_review"REASONING="reasoning"SUMMARIZE="summarize"CREATIVE="creative"# Model assignment based on cost/quality optimizationROUTING_TABLE= {
TaskType.CODE_GEN: "deepseek-coder", # Best code quality, lowest costTaskType.CODE_REVIEW: "deepseek-chat", # Good enough, cheaper than coder variantTaskType.REASONING: "glm-4", # Best context retention for multi-turnTaskType.SUMMARIZE: "deepseek-chat", # Fastest, quality parity across modelsTaskType.CREATIVE: "qwen-plus", # Most natural prose in our evals
}
defroute_and_complete(client: AIWave, task: TaskType, messages: list, **kwargs):
"""Route request to optimal model based on task type."""model=ROUTING_TABLE[task]
returnclient.chat.completions.create(
model=model,
messages=messages,
**kwargs,
)
Real Cost Impact
After implementing this routing layer for a month:
Before (single model, GLM-4 for everything): ~$340/month
After (task-based routing): ~$205/month
Quality impact: No measurable degradation in user satisfaction scores
The biggest savings came from routing summarization and simple code review tasks to DeepSeek, which charges significantly less per million tokens.
Open Questions for the Community
Has anyone tested Kimi K2 for long-context tasks (>100K tokens)? We haven't included it in our benchmark yet and I'm curious about its instruction-following at extreme context lengths.
What's your experience with fallback chains? Currently if a model times out, we retry the same model. Considering falling back to a different model entirely.
Are you caching responses for identical prompts? We're seeing ~12% cache hit rate in production, which further reduces costs.
Would love to hear how others are handling multi-model routing. What's your go-to model for each task type?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
When building applications on top of multiple Chinese LLM APIs, one of the most common architectural questions is: should you route requests to different models based on task type, or just pick one and stick with it?
After running production workloads across DeepSeek V3, Qwen3, and GLM-4 for several months, I want to share some concrete data and a routing pattern that cut our API costs by ~40% without sacrificing output quality.
The Setup
We tested three models across five task categories:
Key Findings
1. Code Generation: DeepSeek V3 dominates
DeepSeek V3 produced functionally correct code at the highest rate in our tests (~87% pass rate on HumanEval-style tasks), but more importantly, its
deepseek-codervariant was significantly cheaper for code-specific workloads:For reference, GLM-4 scored ~79% on the same benchmark at a similar price point, while Qwen3 landed at ~82% but with noticeably more verbose outputs (increasing cost per request).
2. Multi-turn Reasoning: GLM-4 holds context better
This was the surprise. In multi-turn conversations exceeding 10+ rounds, GLM-4 maintained instruction adherence significantly better than the other two. We measured "instruction drift" — how often the model started ignoring or misinterpreting earlier constraints:
If you're building agents or multi-step reasoning pipelines, GLM-4 is worth the slightly higher per-token cost.
3. Summarization: All three are within margin of error
For document summarization (2K-5K token inputs), all three models produced qualitatively similar summaries as rated by human evaluators. The differentiator was speed, not quality:
In our tests, DeepSeek V3 consistently streamed fastest (~65-80 tok/s), Qwen3 was mid-pack (~40-55 tok/s), and GLM-4 was slowest but most stable (~35-45 tok/s with lower variance).
The Routing Strategy
Based on this data, here's the cost-aware routing logic we implemented:
Real Cost Impact
After implementing this routing layer for a month:
The biggest savings came from routing summarization and simple code review tasks to DeepSeek, which charges significantly less per million tokens.
Open Questions for the Community
Has anyone tested Kimi K2 for long-context tasks (>100K tokens)? We haven't included it in our benchmark yet and I'm curious about its instruction-following at extreme context lengths.
What's your experience with fallback chains? Currently if a model times out, we retry the same model. Considering falling back to a different model entirely.
Are you caching responses for identical prompts? We're seeing ~12% cache hit rate in production, which further reduces costs.
Would love to hear how others are handling multi-model routing. What's your go-to model for each task type?
Resources
All reactions