ExLLM.Infrastructure.Config.ProviderCapabilities (ex_llm v0.8.1)
View SourceProvider-level capability tracking for ExLLM.
This module provides information about what features and capabilities each provider supports at the API level, independent of specific models. It helps users understand what operations are available with each provider and assists in provider selection based on required features.
Features
- Provider endpoint discovery (chat, embeddings, images, etc.)
- Authentication method tracking
- Cost tracking availability
- API feature support
- Provider metadata and limitations
- Feature-based provider recommendations
Usage
# Check if a provider supports a specific feature
ExLLM.Infrastructure.Config.ProviderCapabilities.supports?(:openai, :embeddings)
# Get all capabilities for a provider
{:ok, caps} = ExLLM.Infrastructure.Config.ProviderCapabilities.get_capabilities(:anthropic)
# Find providers that support specific features
providers = ExLLM.Infrastructure.Config.ProviderCapabilities.find_providers_with_features([:embeddings, :streaming])
# Get provider recommendations based on requirements
recommended = ExLLM.Infrastructure.Config.ProviderCapabilities.recommend_providers(%{
required_features: [:streaming, :function_calling],
preferred_features: [:vision, :cost_tracking],
exclude_providers: [:mock]
})
Summary
Functions
Compare capabilities across multiple providers.
Find providers that support all specified features.
Get a provider-specific adapter module.
Get authentication methods for a provider.
Get capabilities for a specific provider.
Get available endpoints for a provider.
Get provider limitations.
Check if a provider is considered "local" (no API calls).
List all known providers.
Get provider recommendations based on requirements.
Check if a provider requires authentication.
Check if a provider supports a specific feature.
Functions
Compare capabilities across multiple providers.
Parameters
providers
- List of provider atoms to compare
Returns
- Map with comparison data
Examples
comparison = ExLLM.Infrastructure.Config.ProviderCapabilities.compare_providers([:openai, :anthropic, :ollama])
Find providers that support all specified features.
Parameters
features
- List of required features
Returns
- List of provider atoms that support all features
Examples
providers = ExLLM.Infrastructure.Config.ProviderCapabilities.find_providers_with_features([:embeddings, :streaming])
# => [:openai, :groq]
Get a provider-specific adapter module.
Parameters
provider
- Provider atom
Returns
- Module atom or nil
Examples
ExLLM.Infrastructure.Config.ProviderCapabilities.get_adapter_module(:openai)
# => ExLLM.Providers.OpenAI
Get authentication methods for a provider.
Parameters
provider
- Provider atom
Returns
- List of authentication methods or empty list
Examples
ExLLM.Infrastructure.Config.ProviderCapabilities.get_auth_methods(:openai)
# => [:api_key, :bearer_token]
@spec get_capabilities(atom()) :: {:ok, ExLLM.Infrastructure.Config.ProviderCapabilities.ProviderInfo.t()} | {:error, :not_found}
Get capabilities for a specific provider.
Parameters
provider
- Provider atom (e.g., :openai, :anthropic)
Returns
{:ok, provider_info}
on success{:error, :not_found}
if provider not found
Examples
{:ok, info} = ExLLM.Infrastructure.Config.ProviderCapabilities.get_capabilities(:openai)
Get available endpoints for a provider.
Parameters
provider
- Provider atom
Returns
- List of available endpoints or empty list
Examples
ExLLM.Infrastructure.Config.ProviderCapabilities.get_endpoints(:openai)
# => [:chat, :embeddings, :images, :audio, :completions, :fine_tuning, :files]
Get provider limitations.
Parameters
provider
- Provider atom
Returns
- Map of limitations or empty map
Examples
ExLLM.Infrastructure.Config.ProviderCapabilities.get_limitations(:ollama)
# => %{no_cost_tracking: true, performance_depends_on_hardware: true}
Check if a provider is considered "local" (no API calls).
Parameters
provider
- Provider atom
Returns
- Boolean
Examples
ExLLM.Infrastructure.Config.ProviderCapabilities.is_local?(:ollama)
# => true
ExLLM.Infrastructure.Config.ProviderCapabilities.is_local?(:openai)
# => false
@spec list_providers() :: [atom()]
List all known providers.
Returns
- List of provider atoms
Examples
ExLLM.Infrastructure.Config.ProviderCapabilities.list_providers()
# => [:anthropic, :bedrock, :bumblebee, :gemini, :groq, :mock, :ollama, :openai, :openrouter, :xai]
Get provider recommendations based on requirements.
Parameters
requirements
- Map with::required_features
- List of features that must be supported:preferred_features
- List of features that are nice to have:required_endpoints
- List of endpoints that must be available:exclude_providers
- List of providers to exclude:prefer_local
- Boolean to prefer local providers (default: false):prefer_free
- Boolean to prefer free providers (default: false)
Returns
- List of recommended providers sorted by match score
Examples
recommendations = ExLLM.Infrastructure.Config.ProviderCapabilities.recommend_providers(%{
required_features: [:streaming, :function_calling],
preferred_features: [:vision, :cost_tracking],
exclude_providers: [:mock]
})
# => [
# %{provider: :openai, score: 1.0, matched_features: [...], missing_features: []},
# %{provider: :anthropic, score: 0.85, matched_features: [...], missing_features: [...]}
# ]
Check if a provider requires authentication.
Parameters
provider
- Provider atom
Returns
- Boolean
Examples
ExLLM.Infrastructure.Config.ProviderCapabilities.requires_auth?(:openai)
# => true
ExLLM.Infrastructure.Config.ProviderCapabilities.requires_auth?(:ollama)
# => false
Check if a provider supports a specific feature.
Parameters
provider
- Provider atomfeature
- Feature to check (endpoint or capability)
Returns
true
if supportedfalse
if not supported or provider not found
Examples
ExLLM.Infrastructure.Config.ProviderCapabilities.supports?(:openai, :embeddings)
# => true
ExLLM.Infrastructure.Config.ProviderCapabilities.supports?(:ollama, :cost_tracking)
# => false