pub struct OpenRouterClient { /* private fields */ }models 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>
Available on crate feature openrouter only.
pub fn new(config: OpenRouterConfig) -> Result<OpenRouterClient, AdkError>
openrouter only.Create a new OpenRouter client with shared default headers.
Sourcepub fn config(&self) -> &OpenRouterConfig
Available on crate feature openrouter only.
pub fn config(&self) -> &OpenRouterConfig
openrouter only.Borrow the immutable client configuration.
Sourcepub fn http_client(&self) -> &Client
Available on crate feature openrouter only.
pub fn http_client(&self) -> &Client
openrouter only.Borrow the shared HTTP client.
Sourcepub fn model(&self) -> &str
Available on crate feature openrouter only.
pub fn model(&self) -> &str
openrouter only.Borrow the configured default model name.
Sourcepub fn with_retry_config(self, retry_config: RetryConfig) -> OpenRouterClient
Available on crate feature openrouter only.
pub fn with_retry_config(self, retry_config: RetryConfig) -> OpenRouterClient
openrouter only.Return a new client value with the provided retry configuration.
Sourcepub fn set_retry_config(&mut self, retry_config: RetryConfig)
Available on crate feature openrouter only.
pub fn set_retry_config(&mut self, retry_config: RetryConfig)
openrouter only.Replace the retry configuration in place.
Sourcepub fn retry_config(&self) -> &RetryConfig
Available on crate feature openrouter only.
pub fn retry_config(&self) -> &RetryConfig
openrouter only.Borrow the active retry configuration.
Sourcepub fn endpoint_url(&self, path: &str) -> String
Available on crate feature openrouter only.
pub fn endpoint_url(&self, path: &str) -> String
openrouter only.Build an absolute endpoint URL for a relative OpenRouter API path.
Sourcepub async fn send_chat(
&self,
request: OpenRouterChatRequest,
) -> Result<OpenRouterChatResponse, AdkError>
Available on crate feature openrouter only.
pub async fn send_chat( &self, request: OpenRouterChatRequest, ) -> Result<OpenRouterChatResponse, AdkError>
openrouter only.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>
Available on crate feature openrouter only.
pub async fn send_chat_stream( &self, request: OpenRouterChatRequest, ) -> Result<Pin<Box<dyn Stream<Item = Result<OpenRouterChatStreamItem, AdkError>> + Send>>, AdkError>
openrouter only.Send a streaming chat-completions request to OpenRouter.
Sourcepub async fn create_response(
&self,
request: OpenRouterResponsesRequest,
) -> Result<OpenRouterResponse, AdkError>
Available on crate feature openrouter only.
pub async fn create_response( &self, request: OpenRouterResponsesRequest, ) -> Result<OpenRouterResponse, AdkError>
openrouter only.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>
Available on crate feature openrouter only.
pub async fn create_response_stream( &self, request: OpenRouterResponsesRequest, ) -> Result<Pin<Box<dyn Stream<Item = Result<OpenRouterResponsesStreamItem, AdkError>> + Send>>, AdkError>
openrouter only.Send a streaming Responses API request to OpenRouter.
Sourcepub async fn list_models(&self) -> Result<Vec<OpenRouterModel>, AdkError>
Available on crate feature openrouter only.
pub async fn list_models(&self) -> Result<Vec<OpenRouterModel>, AdkError>
openrouter only.List models available from OpenRouter discovery.
Sourcepub async fn get_model_endpoints(
&self,
author: &str,
slug: &str,
) -> Result<OpenRouterModelEndpoints, AdkError>
Available on crate feature openrouter only.
pub async fn get_model_endpoints( &self, author: &str, slug: &str, ) -> Result<OpenRouterModelEndpoints, AdkError>
openrouter only.List provider endpoints for a discovered OpenRouter model.
Sourcepub async fn list_providers(&self) -> Result<Vec<OpenRouterProvider>, AdkError>
Available on crate feature openrouter only.
pub async fn list_providers(&self) -> Result<Vec<OpenRouterProvider>, AdkError>
openrouter only.List providers available on OpenRouter.
Sourcepub async fn get_credits(&self) -> Result<OpenRouterCredits, AdkError>
Available on crate feature openrouter only.
pub async fn get_credits(&self) -> Result<OpenRouterCredits, AdkError>
openrouter only.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