utils/model/model_catalog library
Classes
- ModelConfig
- A model configuration across all providers.
- ModelPricing
- Model pricing (per million tokens).
- TokenUsage
- Token usage for cost calculation.
Enums
- ModelFamily
- Model family.
- ModelProvider
- API providers.
Constants
-
modelAliases
→ const Map<
String, String> - Model alias → canonical ID.
-
modelFamilyAliases
→ const Set<
String> - Family aliases (for allowlists).
Properties
-
modelPricing
→ Map<
String, ModelPricing> -
Model pricing table.
final
-
modelRegistry
→ Map<
String, ModelConfig> -
All known model configurations.
final
Functions
-
calculateCost(
String modelId, TokenUsage usage) → double - Calculate cost from token usage.
-
formatCost(
double cost) → String - Format cost as a string.
-
getDefaultModel(
{Map< String, String> ? environment, Map<String, dynamic> ? settings}) → String - Get the default model based on environment and settings.
-
getModelDisplayName(
String modelId) → String - Get display name for a model ID.
-
getProviderModelId(
ModelConfig config, ModelProvider provider) → String? - Get the provider-specific model ID.
-
isModelAllowed(
String modelId, List< String> ? allowlist) → bool - Check if a model is in the allowlist.
-
remapDeprecatedModel(
String modelId) → String - Remap deprecated model IDs to current versions.
-
resolveModel(
String name) → ModelConfig? - Resolve a model name (alias or ID) to a ModelConfig.