# `Sycophant.Registry`

Extensible registry for auth strategies and wire protocols.

Built-in adapters are seeded when the Sycophant application starts.
Library users can register additional adapters from their own
`Application.start/2`:

    Sycophant.Registry.register_auth!(:my_provider, MyApp.Auth.Custom)
    Sycophant.Registry.register_protocol!(:chat, :my_proto, MyApp.WireProtocol.Custom)
    Sycophant.Registry.register_protocol!(:embedding, :my_embed, MyApp.EmbeddingProto.Custom)

Overriding a built-in key is allowed -- the last registration wins.

# `kind`

```elixir
@type kind() :: :chat | :embedding
```

# `fetch_auth`

```elixir
@spec fetch_auth(atom()) :: {:ok, module()} | :error
```

Looks up the auth strategy module for `provider`.

# `fetch_protocol`

```elixir
@spec fetch_protocol(kind(), atom()) :: {:ok, module()} | :error
```

Looks up the protocol adapter module for the given `kind` and `protocol_name`.

# `register_auth!`

```elixir
@spec register_auth!(atom(), module()) :: :ok
```

Registers a custom authentication strategy for the given `provider`.

The `module` must implement the `Sycophant.Auth` behaviour. Raises
`Sycophant.Error.Invalid.InvalidRegistration` if it does not.

    Sycophant.Registry.register_auth!(:my_provider, MyApp.Auth.Custom)

# `register_protocol!`

```elixir
@spec register_protocol!(kind(), atom(), module()) :: :ok
```

Registers a custom protocol adapter under the given `kind` and `protocol_name`.

The `module` must implement `Sycophant.WireProtocol` for `:chat` kind or
`Sycophant.EmbeddingWireProtocol` for `:embedding` kind. Raises
`Sycophant.Error.Invalid.InvalidRegistration` if it does not.

    Sycophant.Registry.register_protocol!(:chat, :my_proto, MyApp.WireProtocol.Custom)
    Sycophant.Registry.register_protocol!(:embedding, :my_embed, MyApp.EmbeddingProto.Custom)

---

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