Skip to main content

Module provider

Module provider 

Source
Expand description

Normalized model access: a provider-agnostic request/response shape, and the wire adapters (Anthropic Messages, OpenAI Chat Completions, Google Gemini) 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.
BedrockProvider
Speaks POST https://bedrock-runtime.{region}.amazonaws.com/model/{model}/invoke (Claude on AWS Bedrock) — an Anthropic-shaped body ([anthropic_messages_body]) authenticated with AWS SigV4 request signing rather than an API key (ADR 0006 P2). Credentials come from the standard AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY / AWS_SESSION_TOKEN env vars, read fresh per call — never logged, never put in the URL (I2).
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.
GeminiProvider
Speaks POST {base}/v1beta/models/{model}:generateContent (Google Gemini Generative Language API). The API key goes in the x-goog-api-key header — never the URL query string, so it stays out of logs and proxies.
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.
VertexProvider
Speaks POST https://{region}-aiplatform.googleapis.com/.../publishers/anthropic/models/{model}:rawPredict (Claude on Google Vertex AI) — an Anthropic-shaped body ([anthropic_messages_body]) authenticated with a GCP OAuth2 bearer token rather than an API key (ADR 0006 P3). The token is minted and cached by gcp_auth from GOOGLE_APPLICATION_CREDENTIALS or the ambient GCP environment — this adapter never caches or logs it, and it never goes in the URL (I2).

Enums§

ProviderError
Failure modes of a provider call.

Traits§

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