pub struct OpenRouterProvider { /* private fields */ }Expand description
The default OpenRouter-backed provider.
Why: Carries the model slug so supports_native_tools can decide per-model
without the loop having to pass the slug on every call.
What: Holds the model slug it was constructed for; the trait methods read it.
Test: openrouter::tests::*.
Implementations§
Source§impl OpenRouterProvider
impl OpenRouterProvider
Sourcepub fn new(slug: impl Into<String>) -> Self
pub fn new(slug: impl Into<String>) -> Self
Construct an OpenRouterProvider for a given model slug.
Why: supports_native_tools is slug-dependent, so the provider must
remember which model it routes for.
What: Stores the slug; all trait behaviour derives from it.
Test: openrouter::tests::supports_native_tools_claude.
Trait Implementations§
Source§impl Clone for OpenRouterProvider
impl Clone for OpenRouterProvider
Source§fn clone(&self) -> OpenRouterProvider
fn clone(&self) -> OpenRouterProvider
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for OpenRouterProvider
impl Debug for OpenRouterProvider
Source§impl Provider for OpenRouterProvider
impl Provider for OpenRouterProvider
Source§fn map_tool_choice(&self, choice: ToolChoice) -> Value
fn map_tool_choice(&self, choice: ToolChoice) -> Value
Translate a neutral
ToolChoice into this backend’s wire JSON. Read moreSource§fn extract_usage(&self, response: &ChatResponse) -> TokenUsage
fn extract_usage(&self, response: &ChatResponse) -> TokenUsage
Extract canonical token usage from a chat response. Read more
Source§fn supports_native_tools(&self) -> bool
fn supports_native_tools(&self) -> bool
Whether the backend/model supports native function-calling. Read more
Source§fn supports_prompt_caching(&self) -> bool
fn supports_prompt_caching(&self) -> bool
Whether this backend/model honours Anthropic-style
cache_control
prompt-cache breakpoints (#2156). Read moreSource§fn wants_detailed_usage(&self) -> bool
fn wants_detailed_usage(&self) -> bool
Whether this backend should be asked for detailed usage accounting
(response-side cache-usage fix). Read more
Auto Trait Implementations§
impl Freeze for OpenRouterProvider
impl RefUnwindSafe for OpenRouterProvider
impl Send for OpenRouterProvider
impl Sync for OpenRouterProvider
impl Unpin for OpenRouterProvider
impl UnsafeUnpin for OpenRouterProvider
impl UnwindSafe for OpenRouterProvider
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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 moreCreates a shared type from an unshared type.