Model Registry & Pricing
easy5 minmodel-registry.ts
You want to pick a model by capability and price — tool support, vision, context size — and estimate what a run will cost.
What it shows
- Look up a model and its pricing with
getModel()andgetPrice() - Filter with
listModels() - Refresh the data from LiteLLM with
initializeModels(), falling back to the built-in list offline
The code
model-registry.ts
import { getModel, getModelRegistry, getPrice, initializeModels, listModels, shutdownModels } from '@cogitator-ai/models';
const claude = getModel('claude-sonnet-5-5');
console.log(`${claude?.displayName}: ${claude?.contextWindow} tokens, $${claude?.pricing.input}/M input`);
const price = getPrice('gpt-6-luna');
if (price) {
const cost = (50_000 / 1_000_000) * price.input + (10_000 / 1_000_000) * price.output;
console.log(`50k in + 10k out on GPT-6 Luna: $${cost.toFixed(4)}`);
}
const cheapToolModels = listModels({
supportsTools: true,
maxPricePerMillion: 2,
excludeDeprecated: true,
});
for (const model of cheapToolModels.slice(0, 5)) {
console.log(` ${model.id} (${model.provider})`);
}
const visionModels = listModels({ supportsVision: true, minContextWindow: 200_000, excludeDeprecated: true });
console.log('Vision models with 200k+ context:', visionModels.map((model) => model.id).join(', '));
try {
await initializeModels();
console.log('Models after fetching LiteLLM data:', getModelRegistry().getModelCount());
} catch {
console.log('Offline: using the built-in model list');
}
shutdownModels();Run it
install · bash
pnpm add @cogitator-ai/modelsrun · bash
npx tsx model-registry.tsOr run the full example from a clone of the repository (keys in .env):
repository · bash
npx tsx examples/core/13-model-registry.ts