ExLLM.Core.Models (ex_llm v0.8.1)
View SourceModel discovery and management across LLM providers.
This module provides unified access to model information, configuration, and discovery across all ExLLM providers.
Summary
Functions
Compare models across different providers.
Find models by capability.
Find models within a cost range (per 1M tokens).
Find models by minimum context window size.
Get the default model for a provider.
Get detailed information about a specific model.
List all available models for all providers.
List models for a specific provider.
Functions
Compare models across different providers.
Returns a comparison matrix showing capabilities, pricing, and context windows.
Examples
iex> ExLLM.Core.Models.compare(["claude-3-5-sonnet-20241022", "gpt-4-turbo", "gemini-1.5-pro"])
{:ok, %{
models: [...],
capabilities: %{vision: [...], streaming: [...]},
pricing: %{...},
context_windows: %{...}
}}
Find models by capability.
Returns models that support all the specified capabilities.
Examples
iex> ExLLM.Core.Models.find_by_capabilities([:vision, :streaming])
{:ok, [
%{provider: :anthropic, id: "claude-3-5-sonnet-20241022", ...},
%{provider: :openai, id: "gpt-4-turbo", ...}
]}
Find models within a cost range (per 1M tokens).
Examples
iex> ExLLM.Core.Models.find_by_cost_range(input: {0, 5.0}, output: {0, 20.0})
{:ok, [%{provider: :openai, id: "gpt-3.5-turbo", pricing: %{input: 0.5, output: 1.5}}, ...]}
@spec find_by_min_context(pos_integer()) :: {:ok, [map()]} | {:error, term()}
Find models by minimum context window size.
Examples
iex> ExLLM.Core.Models.find_by_min_context(100_000)
{:ok, [%{provider: :anthropic, id: "claude-3-5-sonnet-20241022", context_window: 200_000}, ...]}
Get the default model for a provider.
Examples
iex> ExLLM.Core.Models.get_default(:anthropic)
{:ok, "claude-3-5-sonnet-latest"}
Get detailed information about a specific model.
Examples
iex> ExLLM.Core.Models.get_info(:anthropic, "claude-3-5-sonnet-20241022")
{:ok, %{
id: "claude-3-5-sonnet-20241022",
provider: :anthropic,
name: "Claude 3.5 Sonnet",
context_window: 200_000,
max_output_tokens: 4_096,
capabilities: [:streaming, :vision, :function_calling],
pricing: %{input: 3.0, output: 15.0}
}}
List all available models for all providers.
Returns a list of model information including provider, model ID, and capabilities.
Examples
iex> ExLLM.Core.Models.list_all()
{:ok, [
%{provider: :anthropic, id: "claude-3-5-sonnet-20241022", ...},
%{provider: :openai, id: "gpt-4-turbo", ...},
...
]}
List models for a specific provider.
Examples
iex> ExLLM.Core.Models.list_for_provider(:anthropic)
{:ok, [
%{id: "claude-3-5-sonnet-20241022", name: "Claude 3.5 Sonnet", ...},
%{id: "claude-3-5-haiku-20241022", name: "Claude 3.5 Haiku", ...}
]}