ReqLLM.Capability (ReqLLM v1.0.0)
View SourceModel capability discovery and validation.
Provides programmatic interface to query what features are supported by specific models. Capabilities are extracted from provider metadata loaded from models.dev.
Summary
Functions
Get all supported capabilities for a model.
Get all models from a provider that support a specific capability.
Get all available models for a provider.
Get all providers that have models supporting a capability.
Check if a model supports a specific capability.
Check if model supports object generation (structured output).
Validate that a model supports required capabilities from options.
Functions
@spec capabilities(ReqLLM.Model.t() | binary()) :: [atom()]
Get all supported capabilities for a model.
Examples
iex> ReqLLM.Capability.capabilities("anthropic:claude-3-haiku")
[:max_tokens, :system_prompt, :temperature, :tools, :streaming]
Get all models from a provider that support a specific capability.
Examples
iex> ReqLLM.Capability.models_for(:anthropic, :reasoning)
["anthropic:claude-3-5-sonnet-20241022"]
Get all available models for a provider.
Examples
iex> ReqLLM.Capability.provider_models(:anthropic)
["anthropic:claude-3-haiku", "anthropic:claude-3-sonnet"]
Get all providers that have models supporting a capability.
Examples
iex> ReqLLM.Capability.providers_for(:tools)
[:anthropic, :openai, :google]
@spec supports?(ReqLLM.Model.t() | binary(), atom()) :: boolean()
Check if a model supports a specific capability.
Examples
iex> ReqLLM.Capability.supports?("anthropic:claude-3-sonnet", :tools)
true
@spec supports_object_generation?(ReqLLM.Model.t() | binary()) :: boolean()
Check if model supports object generation (structured output).
Different providers implement this via different mechanisms:
- Google: Native JSON mode via responseMimeType
- OpenAI: response_format with json_schema OR strict tools
- Anthropic/Groq/OpenRouter/XAI: Function calling with structured tool
Examples
iex> ReqLLM.Capability.supports_object_generation?("openai:gpt-4o")
true
iex> ReqLLM.Capability.supports_object_generation?("anthropic:claude-3-haiku")
true
@spec validate!( ReqLLM.Model.t() | binary(), keyword() ) :: :ok
Validate that a model supports required capabilities from options.
Options
:on_unsupported-:ignore(default),:warn, or:error
Examples
iex> ReqLLM.Capability.validate!(model, temperature: 0.7)
:ok
iex> ReqLLM.Capability.validate!(model, tools: [...], on_unsupported: :error)
** (ReqLLM.Error.Invalid.Capability) Model does not support [:tools]