pub struct OpenRouterRoutingConfig {
pub models: Vec<String>,
pub route: Option<OpenRouterRoute>,
pub provider: Option<OpenRouterProviderRouting>,
pub plugins: Option<OpenRouterPluginConfig>,
pub capacity_strategy: Option<OpenRouterCapacityStrategy>,
pub presets: Vec<OpenRouterRoutingPreset>,
pub server_tools: Vec<OpenRouterServerTool>,
}Expand description
These fields mirror OpenRouter’s request-level routing extensions. Drivers must only forward this config to OpenRouter-compatible endpoints.
Fields§
§models: Vec<String>Candidate models to try in OpenRouter’s fallback order.
route: Option<OpenRouterRoute>OpenRouter route strategy. Currently fallback is the stable route
value used with models.
provider: Option<OpenRouterProviderRouting>Provider ordering, policy, and sorting preferences.
plugins: Option<OpenRouterPluginConfig>Optional plugin activations (web search, file reader).
capacity_strategy: Option<OpenRouterCapacityStrategy>Org-level capacity strategy. Compiled into provider routing before
dispatch; not forwarded verbatim. None and SharedCapacity are
equivalent (no routing changes).
presets: Vec<OpenRouterRoutingPreset>High-level routing quality/policy presets. Compiled into provider
flags by apply_presets() before the request is serialized.
Explicit provider fields override preset-derived values.
server_tools: Vec<OpenRouterServerTool>OpenRouter server tools (beta) the model may invoke. Provider-executed;
appended to the request tools array as {"type":"openrouter:<name>"}.
Implementations§
Source§impl OpenRouterRoutingConfig
impl OpenRouterRoutingConfig
pub fn is_empty(&self) -> bool
Sourcepub fn fallback_models(
models: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn fallback_models( models: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Build an ordered model-fallback routing config.
pub fn validate_for_primary_model( &self, primary_model: &str, ) -> Result<(), String>
Sourcepub fn apply_capacity_strategy(&self) -> Result<Self, String>
pub fn apply_capacity_strategy(&self) -> Result<Self, String>
Apply the capacity strategy, returning a derived config with provider
routing adjusted accordingly.
SharedCapacity/None— returnsselfunchanged.ByokFirst— setsprovider.allow_fallbacks = truewhen not already set.ByokOnly— requiresprovider.onlyto list at least one provider slug; setsprovider.allow_fallbacks = false.
Returns Err when the strategy constraints cannot be satisfied.
Sourcepub fn apply_presets(&self) -> Result<Self, String>
pub fn apply_presets(&self) -> Result<Self, String>
Compile presets into OpenRouterProviderRouting flags and merge with
any explicit provider overrides. Returns a derived config with the
presets list cleared and provider reflecting the merged result.
Explicit provider fields always win over preset-derived values. When
multiple presets target the same provider field, later presets in the
list override earlier ones.
Returns Err if any preset values are invalid (e.g. negative MaxPrice values).
Trait Implementations§
Source§impl Clone for OpenRouterRoutingConfig
impl Clone for OpenRouterRoutingConfig
Source§fn clone(&self) -> OpenRouterRoutingConfig
fn clone(&self) -> OpenRouterRoutingConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for OpenRouterRoutingConfig
impl Debug for OpenRouterRoutingConfig
Source§impl Default for OpenRouterRoutingConfig
impl Default for OpenRouterRoutingConfig
Source§fn default() -> OpenRouterRoutingConfig
fn default() -> OpenRouterRoutingConfig
Source§impl<'de> Deserialize<'de> for OpenRouterRoutingConfig
impl<'de> Deserialize<'de> for OpenRouterRoutingConfig
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>,
Source§impl PartialEq for OpenRouterRoutingConfig
impl PartialEq for OpenRouterRoutingConfig
Source§fn eq(&self, other: &OpenRouterRoutingConfig) -> bool
fn eq(&self, other: &OpenRouterRoutingConfig) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for OpenRouterRoutingConfig
impl Serialize for OpenRouterRoutingConfig
impl StructuralPartialEq for OpenRouterRoutingConfig
Auto Trait Implementations§
impl Freeze for OpenRouterRoutingConfig
impl RefUnwindSafe for OpenRouterRoutingConfig
impl Send for OpenRouterRoutingConfig
impl Sync for OpenRouterRoutingConfig
impl Unpin for OpenRouterRoutingConfig
impl UnsafeUnpin for OpenRouterRoutingConfig
impl UnwindSafe for OpenRouterRoutingConfig
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> 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