Expand description
Active request router (enterprise#13) — alias + intent-tier model rewrite in the forward path, fail-open by construction.
Runs between body parse and body compression: it may replace the model
field and re-target the request to another upstream of the same wire
shape — or, with the shape-xlat feature (enterprise#16), route an
Anthropic /v1/messages request onto an OpenAI-shape upstream with the
translation flag set. The decision is recorded as routed_from on the
usage record, so savings attribution can prove what the router did
(enterprise#15/#19).
Two rule sources ([proxy.routing], RoutingRules):
- Aliases — exact requested-model match.
"acme/fast" = "foundry:gpt-4o-mini"gives clients a stable org-level name;"claude-opus-4-5" = "claude-sonnet-4-5"transparently downgrades a concrete model. - Tiers — intent classification of the request’s last user message
(
intent_engine::classify→route_intent→fast|standard|premium) picks the target from thetierstable. Unset/empty tier = keep the requested model.
Every failure mode — no rules, no model field, unknown target provider, shape mismatch, unextractable query — routes nothing: the request forwards unchanged. A routing bug can cost savings, never availability.
Structs§
- Route
Decision - What the router decided for one request. Applied by the forward path:
modelalready swapped in the body byroute_request; the caller re-targets the upstream and injects the registry credential if set.
Functions§
- route_
request - Applies the routing rules to a parsed request body. On a routing decision
the body’s
modelfield is rewritten in place and the full decision is returned; on any miss/failure the body is untouched andNoneis returned (fail-open passthrough).