pub struct OpenRouterConfig {
pub api_key: String,
pub model: String,
pub base_url: String,
pub http_referer: Option<String>,
pub title: Option<String>,
pub default_api_mode: OpenRouterApiMode,
}Available on crate feature
models only.Expand description
OpenRouter configuration shared by native APIs and the Llm adapter.
Fields§
§api_key: StringOpenRouter API key.
model: StringDefault model name.
base_url: StringBase URL for the OpenRouter API.
http_referer: Option<String>Optional site URL sent as HTTP-Referer.
title: Option<String>Optional app title sent as X-OpenRouter-Title and X-Title.
default_api_mode: OpenRouterApiModeDefault API mode used when the generic Llm adapter is invoked.
Implementations§
Source§impl OpenRouterConfig
impl OpenRouterConfig
Sourcepub fn new(
api_key: impl Into<String>,
model: impl Into<String>,
) -> OpenRouterConfig
Available on crate feature openrouter only.
pub fn new( api_key: impl Into<String>, model: impl Into<String>, ) -> OpenRouterConfig
openrouter only.Create a new OpenRouter config using the default API base URL.
Sourcepub fn with_base_url(self, base_url: impl Into<String>) -> OpenRouterConfig
Available on crate feature openrouter only.
pub fn with_base_url(self, base_url: impl Into<String>) -> OpenRouterConfig
openrouter only.Override the API base URL.
Sourcepub fn with_http_referer(
self,
http_referer: impl Into<String>,
) -> OpenRouterConfig
Available on crate feature openrouter only.
pub fn with_http_referer( self, http_referer: impl Into<String>, ) -> OpenRouterConfig
openrouter only.Set the optional HTTP-Referer attribution header.
Sourcepub fn with_title(self, title: impl Into<String>) -> OpenRouterConfig
Available on crate feature openrouter only.
pub fn with_title(self, title: impl Into<String>) -> OpenRouterConfig
openrouter only.Set the optional OpenRouter app title header.
Sourcepub fn with_default_api_mode(
self,
default_api_mode: OpenRouterApiMode,
) -> OpenRouterConfig
Available on crate feature openrouter only.
pub fn with_default_api_mode( self, default_api_mode: OpenRouterApiMode, ) -> OpenRouterConfig
openrouter only.Set the default API mode used by the generic Llm adapter.
Sourcepub fn effective_base_url(&self) -> &str
Available on crate feature openrouter only.
pub fn effective_base_url(&self) -> &str
openrouter only.Return the normalized API base URL without a trailing slash.
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 from a relative OpenRouter API path.
Sourcepub fn default_headers(&self) -> Result<HeaderMap, AdkError>
Available on crate feature openrouter only.
pub fn default_headers(&self) -> Result<HeaderMap, AdkError>
openrouter only.Build the shared default headers used for all OpenRouter requests.
Trait Implementations§
Source§impl Clone for OpenRouterConfig
impl Clone for OpenRouterConfig
Source§fn clone(&self) -> OpenRouterConfig
fn clone(&self) -> OpenRouterConfig
Returns a duplicate of the value. Read more
1.0.0 · 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 OpenRouterConfig
impl Debug for OpenRouterConfig
Source§impl<'de> Deserialize<'de> for OpenRouterConfig
impl<'de> Deserialize<'de> for OpenRouterConfig
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<OpenRouterConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<OpenRouterConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for OpenRouterConfig
impl Serialize for OpenRouterConfig
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for OpenRouterConfig
impl RefUnwindSafe for OpenRouterConfig
impl Send for OpenRouterConfig
impl Sync for OpenRouterConfig
impl Unpin for OpenRouterConfig
impl UnsafeUnpin for OpenRouterConfig
impl UnwindSafe for OpenRouterConfig
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> 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>
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 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>
Wrap the input message
T in a tonic::RequestCreates a shared type from an unshared type.