Skip to main content

Module routing

Module routing 

Source
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):

  1. 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.
  2. Tiers — intent classification of the request’s last user message (intent_engine::classifyroute_intentfast|standard|premium) picks the target from the tiers table. 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§

RouteDecision
What the router decided for one request. Applied by the forward path: model already swapped in the body by route_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 model field is rewritten in place and the full decision is returned; on any miss/failure the body is untouched and None is returned (fail-open passthrough).