Skip to main content

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 single model available through a provider, with its metadata.
23#[derive(Debug, Clone)]
24pub struct ModelEntry {
25    /// The upstream model ID (e.g. "gpt-4o", "claude-sonnet-4-20250514").
26    pub id: String,
27    /// The provider that offers this model.
28    pub provider: String,
29    /// Human-readable display name.
30    pub name: Option<String>,
31    /// Brief description of the model's capabilities.
32    pub description: Option<String>,
33    /// Maximum input context window in tokens.
34    pub max_input_tokens: Option<u64>,
35    /// Maximum number of output tokens the model can produce.
36    pub max_output_tokens: Option<u64>,
37    /// Input modalities the model accepts (e.g. "text", "image").
38    pub input_modalities: Vec<String>,
39    /// Output modalities the model can produce.
40    pub output_modalities: Vec<String>,
41}
42
43/// A routing table that maps incoming model names to routing targets (provider + model ID).
44pub trait RoutingTable {
45    /// Routes an incoming model name to a routing target.
46    fn route(
47        &self,
48        incoming_model_name: &str,
49    ) -> impl Future<Output = Result<RoutingTarget>> + Send;
50
51    /// Lists all configured model routes.
52    fn list_routes(&self) -> Vec<RouteEntry> {
53        Vec::new()
54    }
55
56    /// Lists all models available across all configured providers.
57    fn list_models(&self) -> Vec<ModelEntry> {
58        Vec::new()
59    }
60}