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,
}Expand description
OpenRouter configuration shared by native APIs and the Llm adapter.
The API key is redacted from Debug output and omitted when serializing.
Fields§
§api_key: StringOpenRouter API key. Never serialized; deserializing a config without it yields an empty 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>) -> Self
pub fn new(api_key: impl Into<String>, model: impl Into<String>) -> Self
Create a new OpenRouter config using the default API base URL.
Sourcepub fn with_base_url(self, base_url: impl Into<String>) -> Self
pub fn with_base_url(self, base_url: impl Into<String>) -> Self
Override the API base URL.
Sourcepub fn with_http_referer(self, http_referer: impl Into<String>) -> Self
pub fn with_http_referer(self, http_referer: impl Into<String>) -> Self
Set the optional HTTP-Referer attribution header.
Sourcepub fn with_title(self, title: impl Into<String>) -> Self
pub fn with_title(self, title: impl Into<String>) -> Self
Set the optional OpenRouter app title header.
Sourcepub fn with_default_api_mode(self, default_api_mode: OpenRouterApiMode) -> Self
pub fn with_default_api_mode(self, default_api_mode: OpenRouterApiMode) -> Self
Set the default API mode used by the generic Llm adapter.
Sourcepub fn effective_base_url(&self) -> &str
pub fn effective_base_url(&self) -> &str
Return the normalized API base URL without a trailing slash.
Sourcepub fn endpoint_url(&self, path: &str) -> String
pub fn endpoint_url(&self, path: &str) -> String
Build an absolute endpoint URL from a relative OpenRouter API path.
Sourcepub fn default_headers(&self) -> Result<HeaderMap, AdkError>
pub fn default_headers(&self) -> Result<HeaderMap, AdkError>
Build the shared default headers used for all OpenRouter requests.
Trait Implementations§
Source§impl Clone for OpenRouterConfig
impl Clone for OpenRouterConfig
Source§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<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Forget for OpenRouterConfig
impl Freeze for OpenRouterConfig
impl Move for OpenRouterConfig
impl RefUnwindSafe for OpenRouterConfig
impl Send for OpenRouterConfigwhere
RawVecInner: Send,
impl Sync for OpenRouterConfigwhere
RawVecInner: Sync,
impl Unpin for OpenRouterConfig
impl UnsafeUnpin for OpenRouterConfig
impl UnwindSafe for OpenRouterConfigwhere
RawVecInner: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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