Skip to main content

Module provider

Module provider 

Source
Expand description

Normalized model access: a provider-agnostic request/response shape, and the two wire adapters (Anthropic Messages, OpenAI Chat Completions) that speak it. The router (crate::router) only ever talks to Provider; it never knows which wire format is behind a given rung.

Structs§

AnthropicProvider
Speaks POST {base}/v1/messages (Anthropic Messages API).
Auth
BYOK credentials for one request, extracted from headers with env-var fallback.
ChatMessage
One message in a normalized chat conversation. content is either a plain string (the common case — serializes byte-identically to a text message) OR the original array of content blocks (text / tool_use / tool_result / image), forwarded verbatim so tool and multimodal turns survive the enforce path (ADR 0005). Use ChatMessage::text_view to read a text projection for gating.
ModelRequest
A provider-agnostic model request, built once per incoming call and re-used (with model swapped) across every rung of the ladder.
ModelResponse
A provider-agnostic model response.
OpenAiProvider
Speaks POST {base}/v1/chat/completions (OpenAI Chat Completions API).
ProviderRegistry
Lookup from provider id ("anthropic", "openai", …) to the Provider that serves it.

Enums§

ProviderError
Failure modes of a provider call.

Traits§

Provider
A normalized model backend. Implementations translate ModelRequest/ModelResponse to/from one wire API.