pub enum Backend {
OpenAiChat(HttpBackendConfig),
OpenAiResponses(HttpBackendConfig),
Anthropic(HttpBackendConfig),
}Expand description
A configured upstream backend, one variant per built-in wire format.
The variant fixes the wire format, URL path, and auth scheme together so no invalid combination can be constructed.
Variants§
OpenAiChat(HttpBackendConfig)
OpenAI-compatible Chat Completions API.
OpenAiResponses(HttpBackendConfig)
OpenAI Responses API.
Anthropic(HttpBackendConfig)
Anthropic Messages API.
Implementations§
Source§impl Backend
impl Backend
Sourcepub fn wire_format(&self) -> WireFormat
pub fn wire_format(&self) -> WireFormat
The wire format the request IR is encoded to for this backend.
Sourcepub fn url(&self) -> String
pub fn url(&self) -> String
The fully resolved upstream URL for this backend’s endpoint.
Tolerates base URLs that already include the provider path (or a bare
/v1), matching the join rules of the existing native backends.
Sourcepub fn apply_auth(&self, builder: RequestBuilder) -> RequestBuilder
pub fn apply_auth(&self, builder: RequestBuilder) -> RequestBuilder
Applies this backend’s configured auth and version headers to a request builder.
OpenAI variants use Authorization: Bearer <key>; Anthropic uses
x-api-key: <key> plus the required anthropic-version header. A backend
with forward_auth uses the caller’s provider credential instead.
Sourcepub fn extra_headers(&self) -> &BTreeMap<String, String>
pub fn extra_headers(&self) -> &BTreeMap<String, String>
Custom per-backend headers to forward on every call.
Sourcepub fn extra_body(&self) -> &BTreeMap<String, Value>
pub fn extra_body(&self) -> &BTreeMap<String, Value>
Default top-level fields to merge into outbound request bodies.
Sourcepub fn omit_body_fields(&self) -> &BTreeSet<String>
pub fn omit_body_fields(&self) -> &BTreeSet<String>
Top-level fields dropped from outbound request bodies before extra_body is merged.
Sourcepub fn reasoning_effort(&self) -> Option<&str>
pub fn reasoning_effort(&self) -> Option<&str>
Reasoning effort forced on outbound requests, if the target configures one.
Sourcepub fn max_retries(&self) -> u32
pub fn max_retries(&self) -> u32
Additional attempts allowed after the initial request.
Sourcepub fn failure_cooldown(&self) -> Duration
pub fn failure_cooldown(&self) -> Duration
Cooldown after an exhausted transient completion failure.
Sourcepub fn timeout(&self) -> Option<Duration>
pub fn timeout(&self) -> Option<Duration>
Deadline for all attempts and the complete response; None leaves the wait unbounded.
Sourcepub fn is_anthropic(&self) -> bool
pub fn is_anthropic(&self) -> bool
Whether this backend speaks the Anthropic Messages wire format — the only
one with a count_tokens endpoint.
Sourcepub fn count_tokens_url(&self) -> String
pub fn count_tokens_url(&self) -> String
The upstream /v1/messages/count_tokens URL, derived from the same base
URL join as url.