pub struct OpenRouterClient { /* private fields */ }models and openrouter only.Expand description
Shared OpenRouter client used by the native APIs and the Llm adapter.
Implementations§
Source§impl OpenRouterClient
impl OpenRouterClient
Sourcepub fn new(config: OpenRouterConfig) -> Result<OpenRouterClient, AdkError>
pub fn new(config: OpenRouterConfig) -> Result<OpenRouterClient, AdkError>
Create a new OpenRouter client with shared default headers.
Sourcepub fn config(&self) -> &OpenRouterConfig
pub fn config(&self) -> &OpenRouterConfig
Borrow the immutable client configuration.
Sourcepub fn http_client(&self) -> &Client
pub fn http_client(&self) -> &Client
Borrow the shared HTTP client.
Sourcepub fn with_retry_config(self, retry_config: RetryConfig) -> OpenRouterClient
pub fn with_retry_config(self, retry_config: RetryConfig) -> OpenRouterClient
Return a new client value with the provided retry configuration.
Sourcepub fn set_retry_config(&mut self, retry_config: RetryConfig)
pub fn set_retry_config(&mut self, retry_config: RetryConfig)
Replace the retry configuration in place.
Sourcepub fn retry_config(&self) -> &RetryConfig
pub fn retry_config(&self) -> &RetryConfig
Borrow the active retry configuration.
Sourcepub fn endpoint_url(&self, path: &str) -> String
pub fn endpoint_url(&self, path: &str) -> String
Build an absolute endpoint URL for a relative OpenRouter API path.
Sourcepub async fn send_chat(
&self,
request: OpenRouterChatRequest,
) -> Result<OpenRouterChatResponse, AdkError>
pub async fn send_chat( &self, request: OpenRouterChatRequest, ) -> Result<OpenRouterChatResponse, AdkError>
Send a non-streaming chat-completions request to OpenRouter.
Sourcepub async fn send_chat_stream(
&self,
request: OpenRouterChatRequest,
) -> Result<Pin<Box<dyn Stream<Item = Result<OpenRouterChatStreamItem, AdkError>> + Send>>, AdkError>
pub async fn send_chat_stream( &self, request: OpenRouterChatRequest, ) -> Result<Pin<Box<dyn Stream<Item = Result<OpenRouterChatStreamItem, AdkError>> + Send>>, AdkError>
Send a streaming chat-completions request to OpenRouter.
Sourcepub async fn create_response(
&self,
request: OpenRouterResponsesRequest,
) -> Result<OpenRouterResponse, AdkError>
pub async fn create_response( &self, request: OpenRouterResponsesRequest, ) -> Result<OpenRouterResponse, AdkError>
Send a non-streaming Responses API request to OpenRouter.
Sourcepub async fn create_response_stream(
&self,
request: OpenRouterResponsesRequest,
) -> Result<Pin<Box<dyn Stream<Item = Result<OpenRouterResponsesStreamItem, AdkError>> + Send>>, AdkError>
pub async fn create_response_stream( &self, request: OpenRouterResponsesRequest, ) -> Result<Pin<Box<dyn Stream<Item = Result<OpenRouterResponsesStreamItem, AdkError>> + Send>>, AdkError>
Send a streaming Responses API request to OpenRouter.
Sourcepub async fn list_models(&self) -> Result<Vec<OpenRouterModel>, AdkError>
pub async fn list_models(&self) -> Result<Vec<OpenRouterModel>, AdkError>
List models available from OpenRouter discovery.
Sourcepub async fn get_model_endpoints(
&self,
author: &str,
slug: &str,
) -> Result<OpenRouterModelEndpoints, AdkError>
pub async fn get_model_endpoints( &self, author: &str, slug: &str, ) -> Result<OpenRouterModelEndpoints, AdkError>
List provider endpoints for a discovered OpenRouter model.
Sourcepub async fn list_providers(&self) -> Result<Vec<OpenRouterProvider>, AdkError>
pub async fn list_providers(&self) -> Result<Vec<OpenRouterProvider>, AdkError>
List providers available on OpenRouter.
Sourcepub async fn get_credits(&self) -> Result<OpenRouterCredits, AdkError>
pub async fn get_credits(&self) -> Result<OpenRouterCredits, AdkError>
Get the authenticated account’s remaining credits.
Trait Implementations§
Source§impl Llm for OpenRouterClient
impl Llm for OpenRouterClient
fn name(&self) -> &str
fn generate_content<'life0, 'async_trait>(
&'life0 self,
request: LlmRequest,
stream: bool,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<LlmResponse, AdkError>> + Send>>, AdkError>> + Send + 'async_trait>>where
'life0: 'async_trait,
OpenRouterClient: 'async_trait,
Auto Trait Implementations§
impl Freeze for OpenRouterClient
impl !RefUnwindSafe for OpenRouterClient
impl Send for OpenRouterClient
impl Sync for OpenRouterClient
impl Unpin for OpenRouterClient
impl UnsafeUnpin for OpenRouterClient
impl !UnwindSafe for OpenRouterClient
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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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>
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>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request