Models and Registry
Models are defined in src/facade/ml/models.generated.ts and loaded into an
in-memory registry in src/facade/ml/models.ts.
Model Structure
Each Model<TApi> (from src/facade/ml/types.ts) includes:
idandnameapiandproviderbaseUrlreasoning(boolean support flag)inputtypes — an array of"text"and/or"image"costper million tokens:input,output,cacheRead,cacheWritecontextWindowandmaxTokens- optional
headers - optional
compat(only foropenai-completions/openai-responsesAPIs)
Registry Functions
getModel(provider, modelId)returns a single model, throwing if unknown.tryGetModel(provider, modelId)returns the model orundefined.getModels(provider)returns all models for a provider.getProviders()returns the catalog's provider names.findModels(filters?)filters byprovider,api,reasoning,supportsImageInput, andnameIncludes.registerCustomModel(model)adds one model;loadCustomModels(models)adds many.
These delegate to the shared modelRegistry singleton (an instance of the
exported ModelRegistry class). You can also construct your own ModelRegistry
with a custom seed.
import { findModels } from "indusagi/ai";
const reasoningModels = findModels({ reasoning: true, supportsImageInput: true });
Cost Calculation
estimateCost(model, { inputTokens, outputTokens, cacheReadTokens?, cacheWriteTokens? })returns a{ input, output, cacheRead, cacheWrite, total }breakdown.calculateCost(model, usage)mutates and returnsusage.cost, computing each component from the per-millionmodel.costrates.
Cache reads and cache writes are priced separately from input and output tokens.
Reasoning Levels
supportsXhigh(model)returnstrueonly forgpt-5.1-codex-max,gpt-5.2, andgpt-5.2-codex.- Providers that do not support
"xhigh"clamp it to"high"(seeclampReasoningin Streaming Model).
Comparing Models
modelsAreEqual(a, b) returns true when both models share the same id and
provider (and both are non-null).
Compatibility Overrides
Model.compat overrides endpoint behavior for OpenAI-compatible providers. It is
typed as OpenAICompletionsCompat for the openai-completions API and
OpenAIResponsesCompat for openai-responses. See AI Providers
for the full field list.
