Expand description
§Cost-Aware Smart Router
Routes prompts to the cheapest provider meeting the request’s SLA:
- Latency budget (max acceptable latency in ms)
- Quality floor (minimum acceptable quality score)
- Cost ceiling (maximum USD per request)
§Algorithm
- Filter providers: remove unhealthy and those exceeding the latency budget.
- Filter providers: remove those below the quality floor.
- Filter providers: remove those exceeding the cost ceiling.
- If
prefer_qualityis set, select the highest-quality remaining provider. - Otherwise select the cheapest provider that meets all constraints.
- The remaining providers (sorted cheapest-first) become the fallback list.
Pricing is configurable and can be hot-reloaded from a TOML string at
runtime via SmartRouter::load_pricing_toml.
Structs§
- Model
Pricing - Per-token pricing and capability metadata for one provider/model combination.
- Routing
Decision - The result of a routing call: primary provider plus ordered fallbacks.
- Routing
Requirements - SLA constraints for a single routing request.
- Smart
Router - Routes incoming requests to the cheapest (or highest-quality) provider that satisfies all SLA constraints.