ReqLLM.Capability (ReqLLM v1.0.0)

View Source

Model 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

capabilities(model_input)

@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]

models_for(provider, capability)

@spec models_for(atom(), atom()) :: [binary()]

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"]

provider_models(provider)

@spec provider_models(atom()) :: [binary()]

Get all available models for a provider.

Examples

iex> ReqLLM.Capability.provider_models(:anthropic)
["anthropic:claude-3-haiku", "anthropic:claude-3-sonnet"]

providers_for(capability)

@spec providers_for(atom()) :: [atom()]

Get all providers that have models supporting a capability.

Examples

iex> ReqLLM.Capability.providers_for(:tools)
[:anthropic, :openai, :google]

supports?(model_spec, capability)

@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

supports_object_generation?(model_input)

@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

validate!(model, opts)

@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]