# `SuperPi.AI.Providers`
[🔗](https://github.com/oleksandr/super-pi-beam/blob/v0.1.0/lib/super_pi/ai/providers.ex#L1)

Provider registry. Selects the `SuperPi.AI.Provider` that serves a model.

Resolution order:

1. In mock mode (`config :super_pi, mock_llm: true`) only `SuperPi.AI.Providers.Mock` is active.
   Mock mode is for tests and demos. It never turns on by itself.
2. Otherwise the first provider in `config :super_pi, :providers` whose `handles?/1` returns
   true serves the model. The default list is Gemini, Anthropic and OpenAI. A provider with no key is listed in the catalog as not available.
3. If that provider is not configured, or no provider handles the model, the result is an
   error. There is no silent fallback.

# `error`

```elixir
@type error() ::
  {:no_provider, String.t()} | {:not_configured, provider_id :: String.t()}
```

# `active`

```elixir
@spec active() :: [module()]
```

Providers that can serve requests now.

# `catalog`

```elixir
@spec catalog() :: [map()]
```

Model catalog of all registered providers, with the provider id and availability.

# `format_error`

```elixir
@spec format_error(error()) :: String.t()
```

Human-readable message for a resolution error.

# `registered`

```elixir
@spec registered() :: [module()]
```

Providers registered in the application environment.

# `resolve`

```elixir
@spec resolve(String.t()) :: {:ok, module(), String.t()} | {:error, error()}
```

Returns the provider for `model` and the model name to send to it.

---

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