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

StrategyOptimises forTypical trade-off
defaultBalanced P95 latency + costAllround — fine for most apps
cheapestToken priceSlightly higher P95 latency
fastestTime-to-first-token + total latencyUp to +35% cost
bestHighest provider eval qualityUp to +60% cost

Set at construction

cr.ts
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 setGateway behaviour
strategy onlyHint applied within priority sort
provider onlyHard pin — uses that provider or returns 400
bothPin wins. Strategy is ignored for this call
neitherPure 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.