Skip to main content

Module routing

Module routing 

Source
Expand description

Explicit model targets — operator-written aliases in the forward path.

Runs between body parse and body compression: an exact alias match ([proxy.routing.aliases], RoutingRules) 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. "acme/fast" = "foundry:gpt-4o-mini" gives clients a stable org name for an approved endpoint; a local target keeps traffic on-device.

LeanCTX never picks a model on its own. The rewrite is recorded as routed_from on the usage record so the operator can see it happened. Missing rules/model and unavailable target shapes leave the body unchanged.

Structs§

RouteDecision
What an alias resolved to 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 alias rules to a parsed request body. On a match the body’s model field is rewritten in place and the decision is returned; without a match or reachable target the body is untouched and None is returned.