RoutingRouting strategies
Routing strategies
`default`, `cheapest`, `fastest`, `best` — what they optimise for and the trade-offs.
The X-CleverRouter-Strategy header (or { strategy } SDK option)
nudges the gateway toward a preferred provider when more than one
hosts the requested model. It's a hint, not a contract — pinning a
provider explicitly is what gives you a hard guarantee.
The four strategies
| Strategy | Optimises for | Typical trade-off |
|---|---|---|
default | Balanced P95 latency + cost | Allround — fine for most apps |
cheapest | Token price | Slightly higher P95 latency |
fastest | Time-to-first-token + total latency | Up to +35% cost |
best | Highest provider eval quality | Up to +60% cost |
Set at construction
import { createCleverRouter } from '@cleverrouter/sdk';
export const cr = createCleverRouter({
apiKey: process.env.CLEVERROUTER_API_KEY!,
strategy: 'cheapest',
});Every call from this client carries the header.
Set per call
await cr.chat(
{ model: 'meta/llama-3.3-70b', messages },
{ strategy: 'fastest' },
);Via the OpenAI SDK
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env.CLEVERROUTER_API_KEY!,
baseURL: 'https://api.cleverouter.eu/v1',
defaultHeaders: { 'X-CleverRouter-Strategy': 'cheapest' },
});Strategy + pinning interplay
| You set | Gateway behaviour |
|---|---|
strategy only | Hint applied within priority sort |
provider only | Hard pin — uses that provider or returns 400 |
| both | Pin wins. Strategy is ignored for this call |
| neither | Pure priority sort |
Single-provider models
If a model is hosted by only one provider, strategy doesn't
matter — that provider wins.
Strategy is observable
The chosen provider always shows up in X-CleverRouter-Provider
on the response. If your cheapest strategy keeps picking the
same provider, that's because it actually is the cheapest hosting
this model.
Related
- Routing overview — the full 5-step decision.
- Provider pinning — when to give up the hint.
- Pricing — provider cost + 5% markup.