Skip to main content

Provider

Trait Provider 

Source
pub trait Provider:
    Send
    + Sync
    + Debug {
    // Required methods
    fn complete<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        req: &'life1 ModelRequest,
        auth: &'life2 Auth,
    ) -> Pin<Box<dyn Future<Output = Result<ModelResponse, ProviderError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn id(&self) -> &str;

    // Provided method
    fn carries_structured_verbatim(&self, _inbound: Dialect) -> bool { ... }
}
Expand description

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

Required Methods§

Source

fn complete<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, req: &'life1 ModelRequest, auth: &'life2 Auth, ) -> Pin<Box<dyn Future<Output = Result<ModelResponse, ProviderError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Call the model and normalize the result.

§Errors

Returns ProviderError on transport failure, a non-2xx response, or a response that doesn’t decode into the expected shape.

Source

fn id(&self) -> &str

Provider identity, e.g. "anthropic".

Provided Methods§

Source

fn carries_structured_verbatim(&self, _inbound: Dialect) -> bool

Whether this provider carries structured content (tool_use / tool_result / image blocks and top-level tools) verbatim on the wire for the given inbound dialect.

  • Anthropic-dialect providers (Anthropic / Bedrock / Vertex) return true iff inbound == Dialect::Anthropic: the raw inbound body is forwarded with only the model swapped, so every caller field — tools, tool_choice, thinking, … — survives intact (ADR 0005 P4).
  • OpenAiProvider returns true iff inbound == Dialect::Openai: same verbatim-carry rule for all-OpenAI-dialect ladders.
  • All other providers (Gemini, unknown) return false — no verbatim-carry built yet.

The enforce path’s fidelity guard uses this to decide: verbatim-carry path (all rungs return true for the inbound dialect), translation path (OpenAI → Anthropic when content is translatable), or transparent observe passthrough (safe fallback).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§