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 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.
Sourcepub fn extra_headers(&self) -> &BTreeMap<String, String>
pub fn extra_headers(&self) -> &BTreeMap<String, String>
Static 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 max_retries(&self) -> u32
pub fn max_retries(&self) -> u32
Additional attempts allowed after the initial request.
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.