Skip to main content

ModelProvider

Trait ModelProvider 

Source
pub trait ModelProvider:
    Send
    + Sync
    + Debug {
    // Required methods
    fn gen_ai_provider(&self) -> Option<&str>;
    fn complete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        request: Request<'life1>,
    ) -> Pin<Box<dyn Future<Output = Result<Completion, ModelError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided method
    fn request_profile(&self, _model: &ModelId) -> Value { ... }
}
Expand description

Talks to a provider.

Required Methods§

Source

fn gen_ai_provider(&self) -> Option<&str>

The gen_ai.provider.name this driver’s calls report: the GenAI convention’s well-known value for the service it speaks to (openai, anthropic, aws.bedrock, gcp.gemini), or None when it cannot know, and a call reports the name its model is routed by.

Source

fn complete<'life0, 'life1, 'async_trait>( &'life0 self, request: Request<'life1>, ) -> Pin<Box<dyn Future<Output = Result<Completion, ModelError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Complete a prompt.

§Errors

A ModelError that states both what is known about reaching the provider and what was consumed. A driver that reports zero usage for an interrupted stream is telling the budget the call was free.

Provided Methods§

Source

fn request_profile(&self, _model: &ModelId) -> Value

Stable, non-secret configuration that changes the provider wire request.

It is part of ModelCall’s effect identity. A provider switching from native schema enforcement to a forced tool, changing endpoint/API version, or changing streaming behavior must not replay an answer produced under the old transport contract. API keys never belong here, and neither does anything that changes only how this plane waits — a timeout is not part of the request, and two deployments differing only in patience must replay each other’s history.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§