Motivation
Jev and OpenRouter can rate-limit (HTTP 429) or fail briefly (502/503). Right now one hiccup fails route() straight away.
Proposal
- Retry 429, 500, 502, 503 and 504 up to N times (default 2) with exponential backoff plus jitter
- Honor the
Retry-After header when present
- Never retry other 4xx codes
- Make it configurable:
Router(..., max_retries=2)
Stdlib only (time.sleep). No new dependencies.
Where
src/model_router/_http.py, plus passing the setting through from Router.
Done when
Motivation
Jev and OpenRouter can rate-limit (HTTP 429) or fail briefly (502/503). Right now one hiccup fails
route()straight away.Proposal
Retry-Afterheader when presentRouter(..., max_retries=2)Stdlib only (
time.sleep). No new dependencies.Where
src/model_router/_http.py, plus passing the setting through fromRouter.Done when
urlopenand a mocked sleep, so tests stay fast