Skip to content

ModelRegistry

Defined in: core/model-registry.ts:14

new ModelRegistry(): ModelRegistry

ModelRegistry

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

string

Full model identifier

number

Number of input tokens (total, including cached and cache creation)

number

Number of output tokens

number = 0

Number of cached input tokens (subset of inputTokens)

number = 0

Number of cache creation tokens (subset of inputTokens, Anthropic only)

CostEstimate | undefined

CostEstimate if model found, undefined otherwise


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

number

Expected input tokens

number

Expected output tokens

string

Optional provider ID to filter by

ModelSpec | undefined

ModelSpec with lowest total cost, or undefined if no models found


getModelLimits(modelId): ModelLimits | undefined

Defined in: core/model-registry.ts:142

Get context window and output limits for a model

string

Full model identifier

ModelLimits | undefined

ModelLimits if model found, undefined otherwise


getModelsByFeature(feature, providerId?): ModelSpec[]

Defined in: core/model-registry.ts:227

Get all models that support a specific feature

keyof ModelFeatures

Feature to filter by

string

Optional provider ID to filter by

ModelSpec[]

Array of ModelSpec objects that support the feature


getModelSpec(modelId): ModelSpec | undefined

Defined in: core/model-registry.ts:117

Get model specification by model ID

string

Full model identifier, optionally with provider prefix (e.g., ‘gpt-5’, ‘claude-sonnet-4-5-20250929’, ‘anthropic:claude-sonnet-4-5’)

ModelSpec | undefined

ModelSpec if found, undefined otherwise


listModels(providerId?): ModelSpec[]

Defined in: core/model-registry.ts:129

List all models, optionally filtered by provider

string

Optional provider ID to filter by (e.g., ‘openai’, ‘anthropic’)

ModelSpec[]

Array of ModelSpec objects


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

ModelSpec

Complete model specification

void

If spec is missing required fields

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(specs): void

Defined in: core/model-registry.ts:105

Register multiple custom model specifications at once

ModelSpec[]

Array of complete model specifications

void

client.modelRegistry.registerModels([
{ provider: "openai", modelId: "gpt-5", ... },
{ provider: "openai", modelId: "gpt-5-mini", ... }
]);

registerProvider(provider): void

Defined in: core/model-registry.ts:21

Register a provider and collect its model specifications

ProviderAdapter

void


supportsFeature(modelId, feature): boolean

Defined in: core/model-registry.ts:214

Check if a model supports a specific feature

string

Full model identifier

keyof ModelFeatures

Feature to check (‘streaming’, ‘functionCalling’, ‘vision’, etc.)

boolean

true if model supports feature, false otherwise


validateModelConfig(modelId, requestedTokens): boolean

Defined in: core/model-registry.ts:201

Validate that requested token count fits within model limits

string

Full model identifier

number

Total tokens requested (input + output)

boolean

true if valid, false if model not found or exceeds limits