ExLLM.Infrastructure.Config.ModelConfig (ex_llm v0.8.1)

View Source

Model configuration loader for ExLLM.

Loads model information from external YAML configuration files including:

  • Model pricing information
  • Context window sizes
  • Model capabilities
  • Default models per provider

Configuration files are located in config/models/ and organized by provider.

Summary

Functions

Gets all context window information for a provider.

Gets all models for a provider.

Gets all pricing information for a provider.

Gets the capabilities for a specific provider and model.

Gets the context window size for a specific provider and model.

Gets the default model for a provider.

Gets the full configuration for a specific model.

Gets the pricing information for a specific provider and model.

Reloads all configuration from files.

Functions

ensure_cache_table()

get_all_context_windows(provider)

Gets all context window information for a provider.

Returns a map of model names to context window sizes.

Examples

iex> contexts = ExLLM.Infrastructure.Config.ModelConfig.get_all_context_windows(:anthropic)
iex> contexts["claude-3-5-sonnet-20241022"]
200000

get_all_models(provider)

Gets all models for a provider.

Returns a map of model names to their configurations.

Examples

iex> models = ExLLM.Infrastructure.Config.ModelConfig.get_all_models(:anthropic)
iex> Map.keys(models)
["claude-3-5-sonnet-20241022", "claude-3-5-haiku-20241022", ...]

get_all_pricing(provider)

Gets all pricing information for a provider.

Returns a map of model names to pricing maps (with :input and :output keys).

Examples

iex> pricing = ExLLM.Infrastructure.Config.ModelConfig.get_all_pricing(:openai)
iex> pricing["gpt-4o"]
%{input: 2.50, output: 10.00}

get_capabilities(provider, model)

Gets the capabilities for a specific provider and model.

Returns a list of capability atoms, or nil if not found.

Examples

iex> ExLLM.Infrastructure.Config.ModelConfig.get_capabilities(:openai, "gpt-4o")
[:text, :vision, :function_calling, :streaming]

get_context_window(provider, model)

Gets the context window size for a specific provider and model.

Returns the context window size in tokens, or nil if not found.

Examples

iex> ExLLM.Infrastructure.Config.ModelConfig.get_context_window(:openai, "gpt-4o")
128000

iex> ExLLM.Infrastructure.Config.ModelConfig.get_context_window(:anthropic, "claude-3-5-sonnet-20241022")
200000

get_default_model(provider)

Gets the default model for a provider.

Returns the default model name as a string, or nil if not found.

Examples

iex> ExLLM.Infrastructure.Config.ModelConfig.get_default_model(:openai)
"gpt-4.1-mini"

iex> ExLLM.Infrastructure.Config.ModelConfig.get_default_model(:anthropic)
"claude-sonnet-4-20250514"

get_model_config(provider, model)

Gets the full configuration for a specific model.

Returns the model configuration map or nil if not found.

Examples

iex> ExLLM.Infrastructure.Config.ModelConfig.get_model_config(:openai, "gpt-4o")
%{
  context_window: 128000,
  pricing: %{input: 2.50, output: 10.00},
  capabilities: [:streaming, :function_calling]
}

get_pricing(provider, model)

Gets the pricing information for a specific provider and model.

Returns a map with :input and :output pricing per 1M tokens, or nil if the model is not found.

Examples

iex> ExLLM.Infrastructure.Config.ModelConfig.get_pricing(:openai, "gpt-4o")
%{input: 2.50, output: 10.00}

iex> ExLLM.Infrastructure.Config.ModelConfig.get_pricing(:anthropic, "claude-3-5-sonnet-20241022")
%{input: 3.00, output: 15.00}

iex> ExLLM.Infrastructure.Config.ModelConfig.get_pricing(:unknown_provider, "model")
nil

reload_config()

Reloads all configuration from files.

Clears the cache and forces a reload of all configuration files. Useful during development or when configuration files are updated.