ModelRegistry
Defined in: core/model-registry.ts:14
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ModelRegistry():
ModelRegistry
Returns
Section titled “Returns”ModelRegistry
Methods
Section titled “Methods”estimateCost()
Section titled “estimateCost()”estimateCost(
modelId,inputTokens,outputTokens,cachedInputTokens,cacheCreationInputTokens):CostEstimate|undefined
Defined in: core/model-registry.ts:161
Estimate API cost for a given model and token usage
Parameters
Section titled “Parameters”modelId
Section titled “modelId”string
Full model identifier
inputTokens
Section titled “inputTokens”number
Number of input tokens (total, including cached and cache creation)
outputTokens
Section titled “outputTokens”number
Number of output tokens
cachedInputTokens
Section titled “cachedInputTokens”number = 0
Number of cached input tokens (subset of inputTokens)
cacheCreationInputTokens
Section titled “cacheCreationInputTokens”number = 0
Number of cache creation tokens (subset of inputTokens, Anthropic only)
Returns
Section titled “Returns”CostEstimate | undefined
CostEstimate if model found, undefined otherwise
getCheapestModel()
Section titled “getCheapestModel()”getCheapestModel(
inputTokens,outputTokens,providerId?):ModelSpec|undefined
Defined in: core/model-registry.ts:239
Get the most cost-effective model for a given provider and token budget
Parameters
Section titled “Parameters”inputTokens
Section titled “inputTokens”number
Expected input tokens
outputTokens
Section titled “outputTokens”number
Expected output tokens
providerId?
Section titled “providerId?”string
Optional provider ID to filter by
Returns
Section titled “Returns”ModelSpec | undefined
ModelSpec with lowest total cost, or undefined if no models found
getModelLimits()
Section titled “getModelLimits()”getModelLimits(
modelId):ModelLimits|undefined
Defined in: core/model-registry.ts:142
Get context window and output limits for a model
Parameters
Section titled “Parameters”modelId
Section titled “modelId”string
Full model identifier
Returns
Section titled “Returns”ModelLimits | undefined
ModelLimits if model found, undefined otherwise
getModelsByFeature()
Section titled “getModelsByFeature()”getModelsByFeature(
feature,providerId?):ModelSpec[]
Defined in: core/model-registry.ts:227
Get all models that support a specific feature
Parameters
Section titled “Parameters”feature
Section titled “feature”keyof ModelFeatures
Feature to filter by
providerId?
Section titled “providerId?”string
Optional provider ID to filter by
Returns
Section titled “Returns”Array of ModelSpec objects that support the feature
getModelSpec()
Section titled “getModelSpec()”getModelSpec(
modelId):ModelSpec|undefined
Defined in: core/model-registry.ts:117
Get model specification by model ID
Parameters
Section titled “Parameters”modelId
Section titled “modelId”string
Full model identifier, optionally with provider prefix (e.g., ‘gpt-5’, ‘claude-sonnet-4-5-20250929’, ‘anthropic:claude-sonnet-4-5’)
Returns
Section titled “Returns”ModelSpec | undefined
ModelSpec if found, undefined otherwise
listModels()
Section titled “listModels()”listModels(
providerId?):ModelSpec[]
Defined in: core/model-registry.ts:129
List all models, optionally filtered by provider
Parameters
Section titled “Parameters”providerId?
Section titled “providerId?”string
Optional provider ID to filter by (e.g., ‘openai’, ‘anthropic’)
Returns
Section titled “Returns”Array of ModelSpec objects
registerModel()
Section titled “registerModel()”registerModel(
spec):void
Defined in: core/model-registry.ts:55
Register a custom model specification at runtime
Use this to add models that aren’t in the built-in catalog, such as:
- Fine-tuned models with custom pricing
- New models not yet supported by llmist
- Custom deployments with different configurations
Parameters
Section titled “Parameters”Complete model specification
Returns
Section titled “Returns”void
Throws
Section titled “Throws”If spec is missing required fields
Example
Section titled “Example”client.modelRegistry.registerModel({ provider: "openai", modelId: "ft:gpt-4o-2024-08-06:my-org:custom:abc123", displayName: "My Fine-tuned GPT-4o", contextWindow: 128_000, maxOutputTokens: 16_384, pricing: { input: 7.5, output: 30.0 }, knowledgeCutoff: "2024-08", features: { streaming: true, functionCalling: true, vision: true }});registerModels()
Section titled “registerModels()”registerModels(
specs):void
Defined in: core/model-registry.ts:105
Register multiple custom model specifications at once
Parameters
Section titled “Parameters”Array of complete model specifications
Returns
Section titled “Returns”void
Example
Section titled “Example”client.modelRegistry.registerModels([ { provider: "openai", modelId: "gpt-5", ... }, { provider: "openai", modelId: "gpt-5-mini", ... }]);registerProvider()
Section titled “registerProvider()”registerProvider(
provider):void
Defined in: core/model-registry.ts:21
Register a provider and collect its model specifications
Parameters
Section titled “Parameters”provider
Section titled “provider”Returns
Section titled “Returns”void
supportsFeature()
Section titled “supportsFeature()”supportsFeature(
modelId,feature):boolean
Defined in: core/model-registry.ts:214
Check if a model supports a specific feature
Parameters
Section titled “Parameters”modelId
Section titled “modelId”string
Full model identifier
feature
Section titled “feature”keyof ModelFeatures
Feature to check (‘streaming’, ‘functionCalling’, ‘vision’, etc.)
Returns
Section titled “Returns”boolean
true if model supports feature, false otherwise
validateModelConfig()
Section titled “validateModelConfig()”validateModelConfig(
modelId,requestedTokens):boolean
Defined in: core/model-registry.ts:201
Validate that requested token count fits within model limits
Parameters
Section titled “Parameters”modelId
Section titled “modelId”string
Full model identifier
requestedTokens
Section titled “requestedTokens”number
Total tokens requested (input + output)
Returns
Section titled “Returns”boolean
true if valid, false if model not found or exceeds limits