pub trait Model: Sized + Clone {
// Required methods
fn send(
&self,
request: &Request,
) -> impl Future<Output = Result<Response>> + Send;
fn stream(
&self,
request: Request,
) -> impl Stream<Item = Result<StreamChunk>> + Send;
fn active_model(&self) -> CompactString;
// Provided method
fn context_limit(&self, model: &str) -> usize { ... }
}Expand description
Unified LLM provider trait.
Abstracts any LLM provider — single-backend (DeepSeek, Claude) or
multi-model registry (ProviderManager). All implementations take
&Request directly; no associated config type.
Constructors are inherent methods on each provider — never called polymorphically.
Required Methods§
Sourcefn send(
&self,
request: &Request,
) -> impl Future<Output = Result<Response>> + Send
fn send( &self, request: &Request, ) -> impl Future<Output = Result<Response>> + Send
Send a chat completion request.
Sourcefn stream(
&self,
request: Request,
) -> impl Stream<Item = Result<StreamChunk>> + Send
fn stream( &self, request: Request, ) -> impl Stream<Item = Result<StreamChunk>> + Send
Stream a chat completion response.
Sourcefn active_model(&self) -> CompactString
fn active_model(&self) -> CompactString
Get the active/default model name.
Provided Methods§
Sourcefn context_limit(&self, model: &str) -> usize
fn context_limit(&self, model: &str) -> usize
Resolve the context limit for a model name.
Default implementation uses the static prefix-matching map.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.