Behaviour for LLM provider implementations.
Providers receive native request bodies and return LLMProxy.Providers.Result structs.
Wire JSON stays at protocol/provider boundaries.
Summary
Callbacks
Non-streaming call. Body is in the provider's native protocol format.
Non-streaming native passthrough. Routes pass the validated native wire body explicitly.
Extract usage from a non-streaming response body
List of model IDs this provider handles
Provider name, e.g. "anthropic", "openrouter"
The native API protocol this provider speaks (:openai or :anthropic)
Streaming call. Body is in the provider's native protocol format.
Streaming native passthrough. Routes pass the validated native wire body explicitly.
Convert native response to OpenAI chat completion format
Types
@type call_result() :: {:ok, LLMProxy.Providers.Result.t()} | {:error, LLMProxy.Providers.Result.t()}
@type stream() :: Enumerable.t()
@type stream_result() :: {:ok, LLMProxy.Providers.Result.t()} | {:error, LLMProxy.Providers.Result.t()}
@type usage() :: LLMProxy.Usage.t()
Callbacks
@callback call(body :: map(), user_id :: String.t()) :: call_result()
Non-streaming call. Body is in the provider's native protocol format.
@callback call_native(body :: map(), user_id :: String.t()) :: call_result()
Non-streaming native passthrough. Routes pass the validated native wire body explicitly.
Extract usage from a non-streaming response body
@callback models() :: [String.t()]
List of model IDs this provider handles
@callback name() :: String.t()
Provider name, e.g. "anthropic", "openrouter"
@callback native_protocol() :: :openai | :anthropic
The native API protocol this provider speaks (:openai or :anthropic)
@callback stream(body :: map(), user_id :: String.t()) :: stream_result()
Streaming call. Body is in the provider's native protocol format.
@callback stream_native(body :: map(), user_id :: String.t()) :: stream_result()
Streaming native passthrough. Routes pass the validated native wire body explicitly.
Convert native response to OpenAI chat completion format