bitrouter_core/routers/routing_table.rs
1use crate::errors::Result;
2
3/// The target to route a request to.
4pub struct RoutingTarget {
5 /// The provider name to route to.
6 pub provider_name: String,
7 /// The actual upstream provider's model ID to route to.
8 pub model_id: String,
9}
10
11/// A single entry in the route listing, describing a configured model route.
12#[derive(Debug, Clone)]
13pub struct RouteEntry {
14 /// The virtual model name (e.g. "default", "my-gpt4").
15 pub model: String,
16 /// The provider name this model routes to.
17 pub provider: String,
18 /// The API protocol the provider uses ("openai", "anthropic", "google").
19 pub protocol: String,
20}
21
22/// A routing table that maps incoming model names to routing targets (provider + model ID).
23pub trait RoutingTable {
24 /// Routes an incoming model name to a routing target.
25 fn route(
26 &self,
27 incoming_model_name: &str,
28 ) -> impl Future<Output = Result<RoutingTarget>> + Send;
29
30 /// Lists all configured model routes.
31 fn list_routes(&self) -> Vec<RouteEntry> {
32 Vec::new()
33 }
34}