pub trait Provider: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn model(&self) -> &str;
fn complete<'life0, 'async_trait>(
&'life0 self,
request: CompletionRequest,
) -> Pin<Box<dyn Future<Output = Result<CompletionStream, ProviderError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
An LLM provider that can complete conversations
This trait abstracts over different LLM providers (Anthropic, OpenAI, etc.) allowing the agent to work with any provider implementation.
§Streaming
All completions are streaming. For non-streaming responses, the implementation should return a stream that yields a single event.
§Thread Safety
Providers must be Send + Sync to allow concurrent use from
different async tasks.
Required Methods§
Sourcefn complete<'life0, 'async_trait>(
&'life0 self,
request: CompletionRequest,
) -> Pin<Box<dyn Future<Output = Result<CompletionStream, ProviderError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn complete<'life0, 'async_trait>(
&'life0 self,
request: CompletionRequest,
) -> Pin<Box<dyn Future<Output = Result<CompletionStream, ProviderError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Complete a conversation
Returns a stream of events as the model generates its response.
The stream ends with either MessageEnd or Error.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".