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() - Work offline from the built-in models and the bundled LiteLLM copy, refresh with
initializeModels()
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.length}, for example`, visionModels.slice(0, 5).map((model) => model.id).join(', '));
console.log('Priced offline:', getPrice('deepseek/deepseek-chat'));
await initializeModels();
console.log('Models after initializeModels():', getModelRegistry().getModelCount());
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