Task-Based Routing: How SpiderGate Maps Intent to Models
The most expensive mistake in LLM ops is using the same model for everything. A simple classification task doesn't need GPT-4o. A complex reasoning chain shouldn't run on a 7B parameter model. But without routing infrastructure, the default is to pick one model and use it everywhere.
The Alias System
SpiderGate introduces model aliases — logical names that resolve to physical providers based on rules you define:
| Alias | Resolves To | Use Case | |-------|------------|----------| | fast | GPT-4o-mini → Gemini Flash | Classification, extraction, simple Q&A | | smart | Claude Sonnet → GPT-4o | Reasoning, analysis, long-context | | code | Claude Sonnet → GPT-4o | Code generation, refactoring | | vision | GPT-4o → Gemini Pro | Image analysis, OCR | | embed | text-embedding-3-small | Vector embeddings |
Your agents call model: "fast" and the gateway handles the rest.
Fallback Chains
Every alias can define an ordered fallback chain. If the primary provider is down, rate-limited, or returning errors, SpiderGate automatically routes to the next provider:
aliases:
smart:
primary: anthropic/claude-sonnet-4-20250514
fallbacks:
- openai/gpt-4o
- google/gemini-1.5-pro
max_latency_ms: 30000
retry_on: [429, 500, 502, 503]The agent never sees the failover. The response comes back in the same format regardless of which provider served it.
Cost Optimization
The routing layer enables automatic cost optimization without sacrificing quality:
Prompt complexity scoring — short, simple prompts get routed to cheaper models
Token budget awareness — if a brand is approaching its monthly cap, the gateway favors cost-effective alternatives
A/B routing — split traffic between providers to benchmark quality and cost
In practice, teams using task-based routing see 40-60% cost reduction compared to single-model deployments.
Configuration
Aliases are defined per-brand in the SpiderGate admin panel or via the API:
curl -X PUT https://gate.spideriq.ai/api/v1/admin/aliases/fast \
-H "Authorization: Bearer sg_admin_xxx" \
-d '{
"primary": "openai/gpt-4o-mini",
"fallbacks": ["google/gemini-2.0-flash"],
"max_tokens": 4096,
"temperature_override": null
}'Real-World Example
Consider an agency running three agent types:
Lead qualifier — reads a business profile, scores it. Needs speed, not depth →
fastEmail writer — crafts personalized outreach. Needs creativity →
smartCode deployer — generates and validates website components →
code
Without routing, all three hit GPT-4o at $2.50/1M input tokens. With aliases:
Lead qualifier on GPT-4o-mini: $0.15/1M (94% savings)
Email writer on Claude Sonnet: $3.00/1M (best quality for the task)
Code deployer on Claude Sonnet: $3.00/1M (best code output)
Blended cost drops dramatically while each task gets the optimal model.
The Key Insight
Routing isn't about picking the cheapest model. It's about matching capability to intent. SpiderGate's alias system makes this declarative — you define what "fast" means for your team, and every agent benefits.
