# `LLMDB.Provider`
[🔗](https://github.com/agentjido/llm_db/blob/main/lib/llm_db/provider.ex#L1)

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](pricing-and-billing.md).

# `t`

```elixir
@type t() :: %LLMDB.Provider{
  alias_of: nil | nil | atom(),
  base_url: nil | nil | binary(),
  catalog_only: boolean(),
  config_schema:
    nil
    | nil
    | [
        %{
          optional(:default) =&gt; nil | any(),
          :name =&gt; binary(),
          :type =&gt; binary(),
          optional(:doc) =&gt; nil | binary(),
          required: boolean()
        }
      ],
  doc: nil | nil | binary(),
  env: nil | nil | [binary()],
  exclude_models: nil | nil | [binary()],
  extra: nil | nil | map(),
  id: atom(),
  name: nil | nil | binary(),
  pricing_defaults:
    nil
    | nil
    | %{
        optional(:currency) =&gt; nil | binary(),
        components: [
          %{
            :id =&gt; binary(),
            optional(:unit) =&gt; nil | binary(),
            optional(:kind) =&gt; nil | binary(),
            optional(:tool) =&gt; nil | atom() | binary(),
            optional(:per) =&gt; nil | integer(),
            optional(:rate) =&gt; nil | number(),
            optional(:meter) =&gt; nil | binary(),
            optional(:size_class) =&gt; nil | binary(),
            optional(:notes) =&gt; nil | binary()
          }
        ]
      },
  runtime:
    nil
    | nil
    | %{
        optional(:auth) =&gt;
          nil
          | %{
              :env =&gt; [binary()],
              optional(:type) =&gt; nil | binary(),
              :headers =&gt; [
                %{
                  optional(:env) =&gt; nil | binary(),
                  :name =&gt; binary(),
                  optional(:value) =&gt; nil | binary()
                }
              ],
              optional(:header_name) =&gt; nil | binary(),
              optional(:query_name) =&gt; nil | binary()
            },
        optional(:base_url) =&gt; nil | binary(),
        optional(:doc_url) =&gt; nil | binary(),
        :default_headers =&gt; map(),
        :default_query =&gt; map(),
        optional(:config_schema) =&gt;
          nil
          | [
              %{
                optional(:default) =&gt; nil | any(),
                :name =&gt; binary(),
                :type =&gt; binary(),
                optional(:doc) =&gt; nil | binary(),
                required: boolean()
              }
            ]
      }
}
```

# `new`

```elixir
@spec new(map()) :: {:ok, t()} | {:error, term()}
```

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}

# `new!`

```elixir
@spec new!(map()) :: t()
```

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

# `schema`

Returns the Zoi schema for Provider

---

*Consult [api-reference.md](api-reference.md) for complete listing*
