Advanced Features

Custom Routing

TokSpan automatically routes each request to the optimal upstream provider — by cost, capability, or your account’s access tier. Transparent to your application code.

How Routing Works in TokSpan

TokSpan uses a smart routing layer. Every model name you call is resolved to the best upstream provider and model for that request — automatically, with no changes to your code.

Routing is fully automatic. You never configure channels or priorities — just call the model name you want and TokSpan picks the best backend.

Common Routing Patterns

Cost-Optimized Routing

Call a generic model name like gpt-4o and TokSpan sends it to the most cost-effective provider currently available.

Per-Key Routing

Create separate API keys for different purposes, each scoped to the models and budget you need:

  • Cost-sensitive workloads → A key limited to budget models (GPT mini, Gemini Flash, DeepSeek)
  • Premium workloads → A key with access to flagship models (GPT, Claude Opus, Gemini Pro)
  • Client-facing apps → A key with a per-key budget cap to keep spend predictable

Capability-Based Routing

TokSpan internally groups models by capability and routes each workload to the best-fit model:

  • Coding assistance — Routed to code-optimized models (Claude Opus / GPT / DeepSeek)
  • Content writing — Routed to models balancing quality and speed (Claude Sonnet / GPT / Gemini Pro)
  • Data analysis — Routed to models with the largest context windows
Key scoping lets you limit which models each key can access. See Authentication — Key Scoping for details.