Skip to main content

ModelProvider

Trait ModelProvider 

Source
pub trait ModelProvider: Send + Sync {
    // Required methods
    fn capabilities(&self) -> &Capabilities;
    fn chat<'life0, 'async_trait>(
        &'life0 self,
        request: ChatRequest,
        ctx: StreamContext,
    ) -> Pin<Box<dyn Future<Output = Result<FinalResponse>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Provider-facing interface. A ModelProvider impl owns whatever HTTP client / state it needs and exposes chat() — that’s the whole surface.

Required Methods§

Source

fn capabilities(&self) -> &Capabilities

Capabilities the provider advertises. The reducer reads this when building the outgoing ChatRequest (e.g. whether to attach reasoning controls).

Source

fn chat<'life0, 'async_trait>( &'life0 self, request: ChatRequest, ctx: StreamContext, ) -> Pin<Box<dyn Future<Output = Result<FinalResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Stream a chat turn. Typed events flow through ctx.sink; the returned FinalResponse carries token usage and the Anthropic thinking-signature (opaque blob required to continue extended thinking across turns).

Cancellation: the provider MUST select! on ctx.token. cancelled() inside any await that could block for more than a few hundred ms. This is the contract that replaces the old check_interrupt polling pattern.

Implementors§