pub struct OpenRouterRequestOptions {Show 24 fields
pub api_mode: Option<OpenRouterApiMode>,
pub models: Option<Vec<String>>,
pub route: Option<String>,
pub plugins: Option<Vec<OpenRouterPlugin>>,
pub response_tools: Option<Vec<OpenRouterResponseTool>>,
pub provider: Option<OpenRouterProviderPreferences>,
pub reasoning: Option<OpenRouterReasoningConfig>,
pub reasoning_content: Option<String>,
pub reasoning_details: Option<Value>,
pub previous_response_id: Option<String>,
pub prompt_cache_key: Option<String>,
pub modalities: Option<Vec<String>>,
pub include: Option<Vec<String>>,
pub image_config: Option<OpenRouterImageConfig>,
pub metadata: Option<Value>,
pub instructions: Option<String>,
pub session_id: Option<String>,
pub trace: Option<Value>,
pub user: Option<String>,
pub tool_choice: Option<OpenRouterToolChoice>,
pub parallel_tool_calls: Option<bool>,
pub response_text: Option<OpenRouterResponseTextConfig>,
pub response_format: Option<OpenRouterResponseFormat>,
pub extra: BTreeMap<String, Value>,
}models and openrouter only.Expand description
Agent-facing OpenRouter options serialized into GenerateContentConfig::extensions["openrouter"].
These options let callers select the native OpenRouter API mode and pass OpenRouter-specific request parameters through the generic ADK request layer without losing them during serialization.
§Example
use adk_core::GenerateContentConfig;
use adk_model::openrouter::{OpenRouterApiMode, OpenRouterRequestOptions};
let mut config = GenerateContentConfig::default();
OpenRouterRequestOptions::default()
.with_api_mode(OpenRouterApiMode::Responses)
.with_route("fallback")
.insert_into_config(&mut config)
.expect("options should serialize");
assert!(config.extensions.contains_key("openrouter"));Fields§
§api_mode: Option<OpenRouterApiMode>§models: Option<Vec<String>>§route: Option<String>§plugins: Option<Vec<OpenRouterPlugin>>§response_tools: Option<Vec<OpenRouterResponseTool>>§provider: Option<OpenRouterProviderPreferences>§reasoning: Option<OpenRouterReasoningConfig>§reasoning_content: Option<String>§reasoning_details: Option<Value>§previous_response_id: Option<String>§prompt_cache_key: Option<String>§modalities: Option<Vec<String>>§include: Option<Vec<String>>§image_config: Option<OpenRouterImageConfig>§metadata: Option<Value>§instructions: Option<String>§session_id: Option<String>§trace: Option<Value>§user: Option<String>§tool_choice: Option<OpenRouterToolChoice>§parallel_tool_calls: Option<bool>§response_text: Option<OpenRouterResponseTextConfig>§response_format: Option<OpenRouterResponseFormat>§extra: BTreeMap<String, Value>Implementations§
Source§impl OpenRouterRequestOptions
impl OpenRouterRequestOptions
Sourcepub fn with_api_mode(
self,
api_mode: OpenRouterApiMode,
) -> OpenRouterRequestOptions
pub fn with_api_mode( self, api_mode: OpenRouterApiMode, ) -> OpenRouterRequestOptions
Set the native OpenRouter API mode used by the adapter.
Sourcepub fn with_models(self, models: Vec<String>) -> OpenRouterRequestOptions
pub fn with_models(self, models: Vec<String>) -> OpenRouterRequestOptions
Set fallback models for OpenRouter routing.
Sourcepub fn with_route(self, route: impl Into<String>) -> OpenRouterRequestOptions
pub fn with_route(self, route: impl Into<String>) -> OpenRouterRequestOptions
Set OpenRouter route selection.
Sourcepub fn with_plugin(self, plugin: OpenRouterPlugin) -> OpenRouterRequestOptions
pub fn with_plugin(self, plugin: OpenRouterPlugin) -> OpenRouterRequestOptions
Append one chat plugin.
Sourcepub fn with_response_tool(
self,
tool: OpenRouterResponseTool,
) -> OpenRouterRequestOptions
pub fn with_response_tool( self, tool: OpenRouterResponseTool, ) -> OpenRouterRequestOptions
Append one Responses API server tool.
Sourcepub fn with_provider_preferences(
self,
provider: OpenRouterProviderPreferences,
) -> OpenRouterRequestOptions
pub fn with_provider_preferences( self, provider: OpenRouterProviderPreferences, ) -> OpenRouterRequestOptions
Set OpenRouter provider preferences.
Sourcepub fn with_reasoning(
self,
reasoning: OpenRouterReasoningConfig,
) -> OpenRouterRequestOptions
pub fn with_reasoning( self, reasoning: OpenRouterReasoningConfig, ) -> OpenRouterRequestOptions
Set OpenRouter reasoning configuration.
Sourcepub fn with_previous_response_id(
self,
previous_response_id: impl Into<String>,
) -> OpenRouterRequestOptions
pub fn with_previous_response_id( self, previous_response_id: impl Into<String>, ) -> OpenRouterRequestOptions
Set a previous response ID for Responses API chaining.
Sourcepub fn with_prompt_cache_key(
self,
prompt_cache_key: impl Into<String>,
) -> OpenRouterRequestOptions
pub fn with_prompt_cache_key( self, prompt_cache_key: impl Into<String>, ) -> OpenRouterRequestOptions
Set a prompt cache key for the Responses API.
Sourcepub fn with_modalities(
self,
modalities: Vec<String>,
) -> OpenRouterRequestOptions
pub fn with_modalities( self, modalities: Vec<String>, ) -> OpenRouterRequestOptions
Set requested response modalities.
Sourcepub fn with_include(self, include: Vec<String>) -> OpenRouterRequestOptions
pub fn with_include(self, include: Vec<String>) -> OpenRouterRequestOptions
Set Responses API include fields.
Sourcepub fn to_extension_value(&self) -> Result<Value, AdkError>
pub fn to_extension_value(&self) -> Result<Value, AdkError>
Serialize the options into a JSON extension value.
Sourcepub fn from_extension_value(
value: &Value,
) -> Result<OpenRouterRequestOptions, AdkError>
pub fn from_extension_value( value: &Value, ) -> Result<OpenRouterRequestOptions, AdkError>
Deserialize the options from a JSON extension value.
Sourcepub fn from_generate_config(
config: Option<&GenerateContentConfig>,
) -> Result<Option<OpenRouterRequestOptions>, AdkError>
pub fn from_generate_config( config: Option<&GenerateContentConfig>, ) -> Result<Option<OpenRouterRequestOptions>, AdkError>
Extract OpenRouter request options from GenerateContentConfig.
Sourcepub fn insert_into_config(
&self,
config: &mut GenerateContentConfig,
) -> Result<(), AdkError>
pub fn insert_into_config( &self, config: &mut GenerateContentConfig, ) -> Result<(), AdkError>
Insert the serialized options into GenerateContentConfig::extensions.
Trait Implementations§
Source§impl Clone for OpenRouterRequestOptions
impl Clone for OpenRouterRequestOptions
Source§fn clone(&self) -> OpenRouterRequestOptions
fn clone(&self) -> OpenRouterRequestOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for OpenRouterRequestOptions
impl Debug for OpenRouterRequestOptions
Source§impl Default for OpenRouterRequestOptions
impl Default for OpenRouterRequestOptions
Source§fn default() -> OpenRouterRequestOptions
fn default() -> OpenRouterRequestOptions
Source§impl<'de> Deserialize<'de> for OpenRouterRequestOptions
impl<'de> Deserialize<'de> for OpenRouterRequestOptions
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<OpenRouterRequestOptions, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<OpenRouterRequestOptions, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for OpenRouterRequestOptions
impl PartialEq for OpenRouterRequestOptions
Source§impl Serialize for OpenRouterRequestOptions
impl Serialize for OpenRouterRequestOptions
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,
impl StructuralPartialEq for OpenRouterRequestOptions
Auto Trait Implementations§
impl Freeze for OpenRouterRequestOptions
impl RefUnwindSafe for OpenRouterRequestOptions
impl Send for OpenRouterRequestOptions
impl Sync for OpenRouterRequestOptions
impl Unpin for OpenRouterRequestOptions
impl UnsafeUnpin for OpenRouterRequestOptions
impl UnwindSafe for OpenRouterRequestOptions
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> 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>
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