Loading...
const model = prompt.length > 500 ? 'large-model' : 'small-model';
return complete(model, prompt);const route = classify(prompt);
const model = route === 'complex' ? 'large-model' : 'small-model';
log({ route, model });
try {
return await complete(model, prompt);
} catch {
return complete('fallback-model', prompt);
}The route is chosen by task, logged for review and backed by a fallback model on errors.
Common methods are rules by task type, a small classifier model that rates difficulty, or trying a cheap model first and escalating if the answer fails a check.
Routing picks the best model before the request. Fallback switches to another model only after the chosen one fails or times out.
It can if hard tasks go to a small model. Run evals per route to confirm quality holds where it matters.