litellm/litellm-rust/crates/router
Yujong Lee 302ab0b1c2 refactor(rust): add gateway and router hook seams
The Rust gateway now calls hooks at all three request layers, each from its
own layer code:

- gateway: GatewayHooks::pre_call in the shared request::route step every
  handler already goes through, post_call as a layer on the inference router
- router: RouterHooks::filter_deployments inside Router::select
- inference: the existing Interceptors, composed with the cache-key capture
  through a route-neutral Chain

Hooks are stored type-erased (Arc<dyn ...>, DynInterceptors in litellm-host),
so Gateway, Router and the route handlers keep their plain signatures.
Defaults are no-ops; only tests install recorders.
2026-10-06 16:21:44 -07:00
..
src refactor(rust): add gateway and router hook seams 2026-10-06 16:21:44 -07:00
tests refactor(rust): add gateway and router hook seams 2026-10-06 16:21:44 -07:00
Cargo.toml refactor(rust): add gateway and router hook seams 2026-10-06 16:21:44 -07:00
README.md chore(rust): prune inference deps and rewrite layering docs (#44836) 2026-10-06 07:17:27 -07:00

litellm-router scaffolds the model-list setup and deployment lookup portion of Python's litellm.Router. Router::from_model_list(&config.model_list) maps configured public names to provider deployments. Programmatic callers can collect (String, Deployment) entries into a Router

Lookup is exact and returns None for an unknown name. This extraction preserves the gateway's existing behavior: the last entry wins when public names repeat. Multiple deployments per model group, routing strategies, retries, cooldowns, and fallbacks are not implemented yet

The router owns deployment configuration and selection. The gateway handles HTTP errors and responses, while the inference-<fmt> crates execute provider calls and resolve credentials