pub struct OpenRouterProvider {
pub api_key: String,
pub model: String,
}Expand description
Cloud chat provider backed by OpenRouter.
Why: lets callers pick OpenRouter or a local model uniformly through
the ChatProvider trait.
What: stores an API key and model id; POSTs OpenAI-compatible streaming
chat completions with bearer auth and trusty-common branding headers.
Test: shape covered by openrouter_provider_reports_metadata; the
streaming and tool-call paths are covered by integration tests in
downstream crates plus the SSE-pump unit tests in this module.
Fields§
§api_key: String§model: StringImplementations§
Source§impl OpenRouterProvider
impl OpenRouterProvider
Sourcepub fn new(api_key: impl Into<String>, model: impl Into<String>) -> Self
pub fn new(api_key: impl Into<String>, model: impl Into<String>) -> Self
Construct a provider from an API key and model id.
Why: keeps callers from poking the public fields directly so the
struct can grow optional knobs without breaking call sites.
What: stores both fields verbatim.
Test: trivially exercised by openrouter_provider_reports_metadata.
Trait Implementations§
Source§impl ChatProvider for OpenRouterProvider
impl ChatProvider for OpenRouterProvider
Source§fn chat_stream<'life0, 'async_trait>(
&'life0 self,
messages: Vec<ChatMessage>,
tools: Vec<ToolDef>,
tx: Sender<ChatEvent>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn chat_stream<'life0, 'async_trait>(
&'life0 self,
messages: Vec<ChatMessage>,
tools: Vec<ToolDef>,
tx: Sender<ChatEvent>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Stream chat events into
tx. tools empty disables tool use.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