AI Router scores every candidate model on three dimensions: predicted quality, predicted cost and predicted latency. Your preferences decide how much each dimension counts. They are stored on your team and applied server-side to every request, so you do not need to change your application code when you adjust them.
Weightings are boost factors on AI Router's built-in balance of 0.5 quality, 0.4 cost and 0.1 latency. Each factor multiplies its dimension and the result is normalized again, so only the ratio between the three values matters:
quality: 1, costs: 1, latency: 1 keeps the built-in balance.costs: 2 doubles the weight of cost relative to the other two.latency: 0 removes latency from the ranking entirely.At least one factor must be greater than zero.
Choose your preferences during onboarding and change them at any time under Settings → Routing in the dashboard. For each of quality, cost and latency you pick one of:
| Preference | Factor | Effect |
|---|---|---|
| Maximize (quality) / Minimize (cost, latency) | 1 | This dimension becomes the only criterion; the other two are set to Irrelevant (0). |
| Improve | 2 | Doubles the weight of this dimension. |
| Retain | 1 | Built-in weight. |
| Flexible | 0.5 | Halves the weight of this dimension. |
| Irrelevant | 0 | Ignores this dimension. Set automatically when you maximize or minimize another one. |
Preferences that do not match one of these factors (for example a value set through the API) are shown as Custom and kept until you choose a listed preference.
You can override each account preference when creating an individual API key. In the dashboard, open your team, navigate to Settings → API Keys, select New API Key, and expand Router Configuration. For each quality, cost, and latency preference, choose Follows organization to use the team value, or choose Ignore (0), Flexible (0.5), Retain (1), or Improve (2) to set a value for that key. The override is fixed after creation; to change it, issue a new key.
For request-specific routing, provide a weighting object in extra_body. It contains quality, costs, and latency. Each value is a non-negative number and defaults to 1.0 when omitted.
Per-request parameters override your account configuration. When a request sends routing parameters, the AI Router uses those values for that request instead of your account configuration. Requests that hard-code routing parameters will not pick up later changes you make in the dashboard.
Using OpenAI:
Using langchain:
Using langchain.js:
...
client.chat.completions.create(
model="auto",
messages=[<omitted>],
extra_body={
'weighting': {
'quality': 1.5,
'costs': 1.0,
'latency': 0.8,
}
}
)
llm = ChatOpenAI(
model="auto",
base_url='https://api.airouter.io',
model_kwargs={
'extra_body': {
'weighting': {
'quality': 1.5,
'costs': 1.0,
'latency': 0.8,
}
}
}
)
import { ChatOpenAI } from '@langchain/openai';
import { PromptTemplate } from '@langchain/core/prompts';
const llm = new ChatOpenAI({
model: 'auto',
apiKey: '<THE-API-KEY-YOU-GENERATED>',
configuration: { baseURL: "https://api.airouter.io" },
modelKwargs: {
weighting: {
quality: 1.5,
costs: 1.0,
latency: 0.8,
}
}
});
const prompt = PromptTemplate.fromTemplate(
'What is the capital of France?',
);
const chain = prompt.pipe(llm);
const result = await chain.invoke({});