pub struct AiModel {
pub provider: String,
pub provider_model: String,
pub failover: Vec<AiModelTarget>,
pub canary: Vec<AiCanaryVersion>,
pub routing_policy: Option<String>,
pub ab_test: Option<String>,
pub canary_analysis: Option<CanaryAnalysis>,
}Expand description
One model alias mapping (DW-075 ai.models{alias}).
Fields§
§provider: StringName of the ai.providers[] entry that serves this alias.
provider_model: StringThe provider’s own model identifier (e.g. gpt-4o-mini,
claude-sonnet-4-5, gemini-2.5-flash), sent to the provider
in place of the alias.
failover: Vec<AiModelTarget>Ordered failover chain (DW-076): when the primary target
answers 429 or a 5xx, or its transport errors, the gateway
retries the next entry — a DIFFERENT provider/model pair, never
a re-send to the provider that just failed (its upstream’s
breaker owns same-provider retries). The client sees one
response. Absent (the default): no failover, the primary’s
answer is final. Cannot be combined with canary on the same
alias (validation rejects the pairing): failover is an
availability chain for a single logical model; a canary split
is deliberately serving multiple versions at once — mixing the
two would retry a canary request onto the stable version and
silently undo the experiment.
canary: Vec<AiCanaryVersion>Weighted canary split (DW-076): traffic for this alias
distributes across the listed versions by a deterministic
weighted hash of the request id (the same slot semantics as
traffic splitting: ratios hold per request, and re-sending a
request with the same id lands on the same version). Each
version names exactly one provider/model pair and carries no
failover of its own. Absent (the default): no split. Cannot be
combined with failover on the same alias.
routing_policy: Option<String>A routing policy name (DW-085): when set, this alias is served
by the named entry in ai.routing_policies instead of a plain
failover chain or canary split. The policy is evaluated per
request (a FallbackChain policy may call an external classifier
service to decide cheap-vs-expensive; a LatencyCost policy
picks deterministically). Cannot be combined with failover
or canary on the same alias (validation enforces mutual
exclusivity): a policy alias composes over OTHER aliases’
routing plans, so it has no primary provider/model pair of its
own.
ab_test: Option<String>An A/B test name (DW-086): when set, this alias is served by
the named entry in ai.experiments.ab_tests instead of a
plain failover chain, canary split, or routing policy. The
experiment is evaluated per request (a deterministic weighted
pick by request id selects a variant). Cannot be combined
with failover, canary, or routing_policy on the same
alias (validation enforces mutual exclusivity): an experiment
alias composes over OTHER aliases’ routing plans, so it has
no primary provider/model pair of its own.
canary_analysis: Option<CanaryAnalysis>Auto-canary analysis (DW-091): when set, a background controller compares the canary (second version) vs the baseline (first version) on error rate or latency and adjusts the canary split weights automatically. Only valid when the canary has exactly 2 versions (baseline + canary). Weight changes are transient (Generation swap) and revert on config reload.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for AiModel
impl<'de> Deserialize<'de> for AiModel
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 JsonSchema for AiModel
impl JsonSchema for AiModel
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreimpl StructuralPartialEq for AiModel
Auto Trait Implementations§
impl Freeze for AiModel
impl RefUnwindSafe for AiModel
impl Send for AiModel
impl Sync for AiModel
impl Unpin for AiModel
impl UnwindSafe for AiModel
Blanket Implementations§
§impl<T> AnyExt for T
impl<T> AnyExt for T
§fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
T behind reference§fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
T behind mutable reference§fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
T behind Rc pointer§fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
T behind Arc pointer§fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>where
T: Any,
fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>where
T: Any,
T behind Box pointer§fn downcast_move<T>(this: Self) -> Option<T>
fn downcast_move<T>(this: Self) -> Option<T>
Self to T,
useful only in generic context as a workaround for specializationSource§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,
§impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
fn coerce_rc_to(self: Rc<X>) -> Rc<T>
fn coerce_box_to(self: Box<X>) -> Box<T>
fn coerce_ref_to(&self) -> &T
fn coerce_mut_to(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 more