Skip to main content

LLMProvider

Trait LLMProvider 

Source
pub trait LLMProvider: Send + Sync {
    // Required method
    fn stream<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 self,
        context: &'life1 InternalRenderedContext,
        tools: &'life2 [ToolSchema],
        extensions: Option<&'life3 Value>,
        state: Option<&'life4 ProviderRunState>,
    ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Stream<Item = Result<StreamEvent>> + Send + Unpin>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait;

    // Provided methods
    fn context_route(&self) -> Value { ... }
    fn prepare_context_request(
        &self,
        context: &InternalRenderedContext,
        tools: &[ToolSchema],
        extensions: Option<&Value>,
        state: Option<&ProviderRunState>,
    ) -> Result<Value> { ... }
    fn stream_prepared<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>(
        &'life0 self,
        _prepared: &'life1 Value,
        context: &'life2 InternalRenderedContext,
        tools: &'life3 [ToolSchema],
        extensions: Option<&'life4 Value>,
        state: Option<&'life5 ProviderRunState>,
    ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Stream<Item = Result<StreamEvent>> + Send + Unpin>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait,
             'life5: 'async_trait { ... }
    fn create_run_state(&self) -> Option<ProviderRunState> { ... }
    fn runtime_policy(&self) -> RuntimePolicy { ... }
    fn peek_provider_replay(
        &self,
        _content: &str,
        _tool_calls: &[ToolCall],
    ) -> Option<ProviderReplay> { ... }
    fn seed_provider_replay(
        &self,
        _content: &str,
        _tool_calls: &[ToolCall],
        _replay: &ProviderReplay,
    ) { ... }
    fn commit_stream_replay(&self, _content: &str, _tool_calls: &[ToolCall]) { ... }
    fn complete<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        context: &'life1 InternalRenderedContext,
        tools: &'life2 [ToolSchema],
        extensions: Option<&'life3 Value>,
    ) -> Pin<Box<dyn Future<Output = Result<CoreMessage>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait { ... }
}

Required Methods§

Source

fn stream<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, context: &'life1 InternalRenderedContext, tools: &'life2 [ToolSchema], extensions: Option<&'life3 Value>, state: Option<&'life4 ProviderRunState>, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Stream<Item = Result<StreamEvent>> + Send + Unpin>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Provided Methods§

Source

fn context_route(&self) -> Value

Stable, credential-free route evidence used to freeze Context execution identity. Custom providers may override this with their model, protocol and endpoint identity.

Source

fn prepare_context_request( &self, context: &InternalRenderedContext, tools: &[ToolSchema], extensions: Option<&Value>, state: Option<&ProviderRunState>, ) -> Result<Value>

Freeze the material covered by a Context request fingerprint before I/O. The default scope is logical adapter input. Providers with hidden encoding state must override this and stream_prepared to consume the same frozen encoded request.

Source

fn stream_prepared<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>( &'life0 self, _prepared: &'life1 Value, context: &'life2 InternalRenderedContext, tools: &'life3 [ToolSchema], extensions: Option<&'life4 Value>, state: Option<&'life5 ProviderRunState>, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Stream<Item = Result<StreamEvent>> + Send + Unpin>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, 'life5: 'async_trait,

Dispatch previously frozen material. The default supports stateless logical adapters; encoded-request providers override this to avoid re-encoding after evidence is recorded.

Source

fn create_run_state(&self) -> Option<ProviderRunState>

Optional per-run state for protocol-native continuation (e.g. Responses API).

Source

fn runtime_policy(&self) -> RuntimePolicy

Per-model runtime policy. Overridden by RuntimeOptions fields when set.

Source

fn peek_provider_replay( &self, _content: &str, _tool_calls: &[ToolCall], ) -> Option<ProviderReplay>

Source

fn seed_provider_replay( &self, _content: &str, _tool_calls: &[ToolCall], _replay: &ProviderReplay, )

Source

fn commit_stream_replay(&self, _content: &str, _tool_calls: &[ToolCall])

Source

fn complete<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, context: &'life1 InternalRenderedContext, tools: &'life2 [ToolSchema], extensions: Option<&'life3 Value>, ) -> Pin<Box<dyn Future<Output = Result<CoreMessage>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Non-streaming completion — default collects from stream.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§