Expand description
Unified routing engine for LLM and Agent providers.
This crate provides capability-based routing that works with both LLM models and spawned agents, using the same routing logic.
§Example
use terraphim_router::{Router, RoutingContext};
fn route_task() {
let router = Router::new();
let decision = router.route(
"Implement a secure authentication system",
&RoutingContext::default(),
).unwrap();
println!("Routed to: {}", decision.provider.id);
}Re-exports§
pub use engine::Router;pub use engine::RoutingEngine;pub use fallback::FallbackRouter;pub use fallback::FallbackStrategy;pub use keyword::KeywordRouter;pub use knowledge_graph::KnowledgeGraphRouter;pub use metrics::RouterMetrics;pub use metrics::Timer;pub use registry::ProviderRegistry;pub use registry::RegistryEvent;pub use strategy::CapabilityFirst;pub use strategy::CostOptimized;pub use strategy::LatencyOptimized;pub use strategy::PreferenceFilter;pub use strategy::RoundRobin;pub use strategy::RoutingStrategy;pub use strategy::StrategyRegistry;pub use strategy::WeightedStrategy;pub use types::RoutingContext;pub use types::RoutingDecision;pub use types::RoutingError;pub use types::RoutingResult;
Modules§
- engine
- Routing engine that orchestrates the routing process.
- fallback
- Fallback routing for when primary provider fails
- keyword
- Keyword-based capability extraction for routing.
- knowledge_
graph - Knowledge graph integration for smart routing
- metrics
- Metrics and tracing for the router
- registry
- Provider registry for loading and managing providers from markdown files.
- strategy
- Routing strategies for selecting the best provider.
- types
- Types for the routing engine.
Structs§
- Provider
- Re-export capability types for convenience A provider that can fulfill capabilities
Enums§
- Capability
- Re-export capability types for convenience A capability that a provider can fulfill
- Cost
Level - Re-export capability types for convenience Cost level for routing decisions
- Latency
- Re-export capability types for convenience Latency expectation for routing decisions
- Provider
Type - Re-export capability types for convenience Type of provider (LLM or Agent)