# `LLMProxy.Protocol`
[🔗](https://github.com/elixir-vibe/llm_proxy/blob/v0.3.1/lib/llm_proxy/protocol.ex#L1)

Protocol detection and conversion between LLM API formats.

Each protocol module knows how to:
- Render normalized requests to wire format
- Convert responses back to its format
- Handle streaming event conversion

# `protocol`

```elixir
@type protocol() :: :openai | :anthropic
```

# `convert_response`

```elixir
@callback convert_response(response :: map(), from :: protocol(), model :: String.t()) ::
  map()
```

Convert a non-streaming response from source protocol to this protocol's format

# `extract_usage`

```elixir
@callback extract_usage(response :: map()) :: LLMProxy.Providers.Behaviour.usage()
```

Extract usage from a response in this protocol's native format

# `protocol`

```elixir
@callback protocol() :: protocol()
```

Which protocol this module handles

# `get_module`

# `provider_protocol`

```elixir
@spec provider_protocol(module() | nil) :: protocol()
```

Wire protocol a provider speaks natively. Defaults to `:openai` when undeclared.

# `provider_request_body`

```elixir
@spec provider_request_body(LLMProxy.Protocol.Request.t(), module(), String.t()) ::
  map()
```

---

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