pub trait LlmProvider: Send + Sync {
// Required methods
fn complete<'life0, 'async_trait>(
&'life0 self,
request: CompletionRequest,
) -> Pin<Box<dyn Future<Output = Result<CompletionResponse>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn stream<'life0, 'async_trait>(
&'life0 self,
request: CompletionRequest,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<StreamChunk>> + Send>>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn model_id(&self) -> &str;
fn max_tokens(&self) -> usize;
fn provider_name(&self) -> &str;
fn supports_strict_tools(&self) -> bool;
fn supports_streaming_tool_deltas(&self) -> bool;
fn native_tool_format(&self) -> ToolFormat;
}Expand description
Trait for LLM completion providers (Anthropic, OpenAI, OpenRouter, Ollama).
Each provider uses its native SDK and implements this unified interface.
The native_tool_format() method indicates which tool schema format the
provider expects, enabling automatic translation via crates/providers/tool_formats.rs.
Required Methods§
Sourcefn complete<'life0, 'async_trait>(
&'life0 self,
request: CompletionRequest,
) -> Pin<Box<dyn Future<Output = Result<CompletionResponse>> + 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<CompletionResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Send a completion request and return the full response.
Sourcefn stream<'life0, 'async_trait>(
&'life0 self,
request: CompletionRequest,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<StreamChunk>> + Send>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stream<'life0, 'async_trait>(
&'life0 self,
request: CompletionRequest,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<StreamChunk>> + Send>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Send a completion request and return a stream of chunks.
Sourcefn max_tokens(&self) -> usize
fn max_tokens(&self) -> usize
Maximum context window size in tokens.
Sourcefn provider_name(&self) -> &str
fn provider_name(&self) -> &str
Provider name for logging and fallback chain (“anthropic”, “openai”, “openrouter”, “ollama”).
Sourcefn supports_strict_tools(&self) -> bool
fn supports_strict_tools(&self) -> bool
Whether this provider supports strict tool mode (guaranteed schema compliance).
Sourcefn supports_streaming_tool_deltas(&self) -> bool
fn supports_streaming_tool_deltas(&self) -> bool
Whether this provider supports streaming tool call deltas (e.g. Anthropic fine-grained tool streaming).
Sourcefn native_tool_format(&self) -> ToolFormat
fn native_tool_format(&self) -> ToolFormat
The native tool definition format this provider expects.