Provider struct with Zoi schema validation.
Represents an LLM provider with metadata including identity, base URL, environment variables, documentation, and pricing defaults.
Fields
:id- Unique provider identifier atom (e.g.,:openai):name- Display name:base_url- Base API URL (supports template variables like{region}):env- List of environment variable names for credentials:config_schema- Runtime configuration field definitions:doc- Documentation URL:pricing_defaults- Default pricing components applied to all models (see below):exclude_models- Model IDs to exclude from upstream sources:extra- Additional provider-specific data:alias_of- Primary provider ID if this is an alias
Pricing Defaults
The :pricing_defaults field defines default pricing for tools and features
that apply to all models from this provider. This avoids duplicating tool
pricing across every model definition.
%{
currency: "USD",
components: [
%{id: "tool.web_search", kind: "tool", tool: "web_search", unit: "call", per: 1000, rate: 10.0},
%{id: "storage.vectors", kind: "storage", unit: "gb_day", per: 1, rate: 0.10}
]
}Provider defaults are merged with model-specific pricing at load time.
See LLMDB.Pricing and the Pricing and Billing guide.
Summary
Functions
Creates a new Provider struct from a map, validating with Zoi schema.
Creates a new Provider struct from a map, raising on validation errors.
Returns the Zoi schema for Provider
Types
@type t() :: %LLMDB.Provider{ alias_of: nil | atom(), base_url: nil | binary(), config_schema: nil | [ %{ optional(:default) => nil | any(), :name => binary(), :type => binary(), optional(:doc) => nil | binary(), required: boolean() } ], doc: nil | binary(), env: nil | [binary()], exclude_models: nil | [binary()], extra: nil | map(), id: atom(), name: nil | binary(), pricing_defaults: nil | %{ optional(:currency) => nil | binary(), components: [ %{ :id => binary(), optional(:unit) => nil | binary(), optional(:kind) => nil | binary(), optional(:tool) => nil | atom() | binary(), optional(:per) => nil | integer(), optional(:rate) => nil | number(), optional(:meter) => nil | binary(), optional(:size_class) => nil | binary(), optional(:notes) => nil | binary() } ] } }
Functions
Creates a new Provider struct from a map, validating with Zoi schema.
Examples
iex> LLMDB.Provider.new(%{id: :openai, name: "OpenAI"})
{:ok, %LLMDB.Provider{id: :openai, name: "OpenAI"}}
iex> LLMDB.Provider.new(%{})
{:error, _validation_errors}
Creates a new Provider struct from a map, raising on validation errors.
Examples
iex> LLMDB.Provider.new!(%{id: :openai, name: "OpenAI"})
%LLMDB.Provider{id: :openai, name: "OpenAI"}
Returns the Zoi schema for Provider