pub struct OpenRouterModelProvider { /* private fields */ }Implementations§
Source§impl OpenRouterModelProvider
impl OpenRouterModelProvider
pub fn new( alias: &str, credential: Option<&str>, timeout_secs: Option<u64>, ) -> OpenRouterModelProvider
Sourcepub fn with_timeout_secs(self, secs: u64) -> OpenRouterModelProvider
pub fn with_timeout_secs(self, secs: u64) -> OpenRouterModelProvider
Override the HTTP request timeout for LLM API calls.
Sourcepub fn with_max_tokens(self, max_tokens: Option<u32>) -> OpenRouterModelProvider
pub fn with_max_tokens(self, max_tokens: Option<u32>) -> OpenRouterModelProvider
Set the maximum output tokens for API requests.
Sourcepub fn with_extra_body(self, extra: Value) -> OpenRouterModelProvider
pub fn with_extra_body(self, extra: Value) -> OpenRouterModelProvider
Set extra JSON parameters to merge into every API request body.
Keys in extra are inserted at the top level of the serialized request,
overriding any existing keys with the same name.
Trait Implementations§
Source§impl ModelProvider for OpenRouterModelProvider
impl ModelProvider for OpenRouterModelProvider
Source§fn default_base_url(&self) -> Option<&str>
fn default_base_url(&self) -> Option<&str>
Canonical public API endpoint, when there is one. Returned as a
string slice so model_provider impls can serve from
const &'static strs
without allocations. None = model_provider has no universal endpoint
(local model_providers, auth-less CLIs, user-BYO endpoints).Source§fn capabilities(&self) -> ProviderCapabilities
fn capabilities(&self) -> ProviderCapabilities
Query model_provider capabilities.
Source§fn warmup<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
OpenRouterModelProvider: 'async_trait,
fn warmup<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
OpenRouterModelProvider: 'async_trait,
Warm up the HTTP connection pool.
Source§fn list_models<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
OpenRouterModelProvider: 'async_trait,
fn list_models<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
OpenRouterModelProvider: 'async_trait,
Fetch the list of available model IDs for this model_provider. Read more
Source§fn chat_with_system<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
system_prompt: Option<&'life1 str>,
message: &'life2 str,
model: &'life3 str,
temperature: Option<f64>,
) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
OpenRouterModelProvider: 'async_trait,
fn chat_with_system<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
system_prompt: Option<&'life1 str>,
message: &'life2 str,
model: &'life3 str,
temperature: Option<f64>,
) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
OpenRouterModelProvider: 'async_trait,
One-shot chat with optional system prompt. See
simple_chat for
the temperature contract.Source§fn chat_with_history<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [ChatMessage],
model: &'life2 str,
temperature: Option<f64>,
) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
OpenRouterModelProvider: 'async_trait,
fn chat_with_history<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [ChatMessage],
model: &'life2 str,
temperature: Option<f64>,
) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
OpenRouterModelProvider: 'async_trait,
Multi-turn conversation. See
simple_chat for the temperature
contract.Source§fn chat<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
request: ChatRequest<'life1>,
model: &'life2 str,
temperature: Option<f64>,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
OpenRouterModelProvider: 'async_trait,
fn chat<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
request: ChatRequest<'life1>,
model: &'life2 str,
temperature: Option<f64>,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
OpenRouterModelProvider: 'async_trait,
Structured chat API for agent loop callers. See
simple_chat for
the temperature contract.Source§fn supports_native_tools(&self) -> bool
fn supports_native_tools(&self) -> bool
Whether model_provider supports native tool calls over API.
Source§fn supports_streaming(&self) -> bool
fn supports_streaming(&self) -> bool
Whether model_provider supports streaming responses.
Source§fn supports_streaming_tool_events(&self) -> bool
fn supports_streaming_tool_events(&self) -> bool
Whether model_provider can emit structured tool-call stream events.
Source§fn stream_chat(
&self,
request: ChatRequest<'_>,
model: &str,
temperature: Option<f64>,
options: StreamOptions,
) -> Pin<Box<dyn Stream<Item = Result<StreamEvent, StreamError>> + Send>>
fn stream_chat( &self, request: ChatRequest<'_>, model: &str, temperature: Option<f64>, options: StreamOptions, ) -> Pin<Box<dyn Stream<Item = Result<StreamEvent, StreamError>> + Send>>
Structured streaming chat interface. See
simple_chat for the
temperature contract.Source§fn chat_with_tools<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
messages: &'life1 [ChatMessage],
tools: &'life2 [Value],
model: &'life3 str,
temperature: Option<f64>,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
OpenRouterModelProvider: 'async_trait,
fn chat_with_tools<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
messages: &'life1 [ChatMessage],
tools: &'life2 [Value],
model: &'life3 str,
temperature: Option<f64>,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
OpenRouterModelProvider: 'async_trait,
Chat with tool definitions for native function calling support.
See
simple_chat for the temperature contract.Source§fn default_temperature(&self) -> f64
fn default_temperature(&self) -> f64
Temperature used when the caller passes
None. Override per family.Source§fn default_max_tokens(&self) -> u32
fn default_max_tokens(&self) -> u32
Max output tokens used when the caller / config doesn’t set one.
Source§fn default_timeout_secs(&self) -> u64
fn default_timeout_secs(&self) -> u64
HTTP timeout (seconds) used when the caller / config doesn’t set one.
Source§fn default_wire_api(&self) -> &str
fn default_wire_api(&self) -> &str
Wire protocol variant. Either
"responses" (OpenAI Codex-style) or
"chat_completions" (everything else). Providers override to their
native format.Source§fn convert_tools(&self, tools: &[ToolSpec]) -> ToolsPayload
fn convert_tools(&self, tools: &[ToolSpec]) -> ToolsPayload
Convert tool specifications to provider-native format.
Source§fn simple_chat<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
message: &'life1 str,
model: &'life2 str,
temperature: Option<f64>,
) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn simple_chat<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
message: &'life1 str,
model: &'life2 str,
temperature: Option<f64>,
) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Simple one-shot chat (single user message, no explicit system prompt). Read more
Source§fn supports_vision(&self) -> bool
fn supports_vision(&self) -> bool
Whether model_provider supports multimodal vision input.
Source§fn stream_chat_with_system(
&self,
_system_prompt: Option<&str>,
_message: &str,
_model: &str,
_temperature: Option<f64>,
_options: StreamOptions,
) -> Pin<Box<dyn Stream<Item = Result<StreamChunk, StreamError>> + Send>>
fn stream_chat_with_system( &self, _system_prompt: Option<&str>, _message: &str, _model: &str, _temperature: Option<f64>, _options: StreamOptions, ) -> Pin<Box<dyn Stream<Item = Result<StreamChunk, StreamError>> + Send>>
Streaming chat with optional system prompt. See
simple_chat for
the temperature contract.Source§fn stream_chat_with_history(
&self,
messages: &[ChatMessage],
model: &str,
temperature: Option<f64>,
options: StreamOptions,
) -> Pin<Box<dyn Stream<Item = Result<StreamChunk, StreamError>> + Send>>
fn stream_chat_with_history( &self, messages: &[ChatMessage], model: &str, temperature: Option<f64>, options: StreamOptions, ) -> Pin<Box<dyn Stream<Item = Result<StreamChunk, StreamError>> + Send>>
Streaming chat with history. See
simple_chat for the temperature
contract.Auto Trait Implementations§
impl Freeze for OpenRouterModelProvider
impl RefUnwindSafe for OpenRouterModelProvider
impl Send for OpenRouterModelProvider
impl Sync for OpenRouterModelProvider
impl Unpin for OpenRouterModelProvider
impl UnsafeUnpin for OpenRouterModelProvider
impl UnwindSafe for OpenRouterModelProvider
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more