Agent Router
Routers: CRUD, member management, stats, decisions and feedback.
Access it as client.agent_router on a Strongly client, or the same path on AsyncStrongly with await. All methods exist on both with identical signatures.
Quick start
from strongly import Strongly
client = Strongly()
# List (auto-paginates as you iterate)
for agent in client.agent_router.list():
print(agent.id)
Methods
Core
list
list(*, limit: int | None = None) -> SyncPaginator[AgentRouter]
List the routers you can use, a page at a time as you iterate.
create
create(*, name: str, strategy: str, description: str | None = None, members: Sequence[Mapping[str, Any]] | None = None, fallback_behavior: str | None = None, sticky_routing: bool | None = None, health_check: Mapping[str, Any] | None = None, bandit_config: Mapping[str, Any] | None = None, canary_config: Mapping[str, Any] | None = None, semantic_config: Mapping[str, Any] | None = None, complexity_config: Mapping[str, Any] | None = None, content_type_config: Mapping[str, Any] | None = None, token_budget_config: Mapping[str, Any] | None = None, routellm_config: Mapping[str, Any] | None = None, custom_strategy: Mapping[str, Any] | None = None) -> AgentRouter
Create a router and return it.
Parameters
name(str): Router name (required).strategy(str): Routing strategy (required):priority,weighted,round-robin,latency-optimized,thompson_sampling,ucb1,epsilon_greedy,linucb,complexity,content-type,token-budget,semantic,routellm,canaryorcustom.description(str | None, optional): Router description.members(Sequence[Mapping[str, Any]] | None, optional):{"model_id", "weight", "priority" (lower = preferred), "enabled", "capabilities"}dicts.fallback_behavior(str | None, optional):next(fail over by priority) orerror.sticky_routing(bool | None, optional):weighted: the same caller always gets the same member.health_check(Mapping[str, Any] | None, optional):{"enabled", "interval_seconds", "failure_threshold", "recovery_threshold"}.bandit_config(Mapping[str, Any] | None, optional): learning strategies:{"reward_metric": success|latency|feedback, "epsilon" (epsilon_greedy), "exploration_bonus" (ucb1 c, linucb alpha), "max_latency_ms", "linucb_features" (linucb)}.canary_config(Mapping[str, Any] | None, optional):{"control_model_id", "canary_model_id", "canary_percent"}.semantic_config(Mapping[str, Any] | None, optional):{"embedding_model_id", "confidence_threshold", "default_model_id", "routes": [{"name", "model_id", "examples"}]}.complexity_config(Mapping[str, Any] | None, optional):{"simple_model_id", "complex_model_id"?}.content_type_config(Mapping[str, Any] | None, optional):{"type_model_map", "default_model_id"}.token_budget_config(Mapping[str, Any] | None, optional):{"long_response_tokens", "short_model_id"}.routellm_config(Mapping[str, Any] | None, optional):{"embedding_model_id" (text-embedding-3-small), "threshold"}.custom_strategy(Mapping[str, Any] | None, optional):{"code"}: Python that setsresultto a member id.
retrieve
retrieve(router_id: str) -> AgentRouter
Retrieve a single router by id.
update
update(router_id: str, *, name: str | None = None, strategy: str | None = None, description: str | None = None, members: Sequence[Mapping[str, Any]] | None = None, fallback_behavior: str | None = None, sticky_routing: bool | None = None, health_check: Mapping[str, Any] | None = None, bandit_config: Mapping[str, Any] | None = None, canary_config: Mapping[str, Any] | None = None, semantic_config: Mapping[str, Any] | None = None, complexity_config: Mapping[str, Any] | None = None, content_type_config: Mapping[str, Any] | None = None, token_budget_config: Mapping[str, Any] | None = None, routellm_config: Mapping[str, Any] | None = None, custom_strategy: Mapping[str, Any] | None = None) -> AgentRouter
Update a router and return it (arguments as in create).
What a learning router has learned is kept.
delete
delete(router_id: str) -> None
Delete a router. Raises on failure; returns nothing.
Other
add_member
add_member(router_id: str, *, model_id: str, weight: float | None = None, priority: int | None = None, enabled: bool | None = None, capabilities: Sequence[str] | None = None) -> AgentRouter
Add a member model to a router and return the updated router.
Parameters
router_id(str): Router id.model_id(str): Model id to add (required).weight(float | None, optional): Relative share of traffic (for the weighted strategy).priority(int | None, optional): Priority, lower = preferred.enabled(bool | None, optional): Whether the member is enabled (default true server-side).capabilities(Sequence[str] | None, optional): Content types it handles (content-type strategy).
decisions
decisions(router_id: str, *, limit: int | None = None) -> SyncPaginator[RouterDecision]
List the router's decisions, newest first, a page at a time as you iterate.
Each has the strategy's reason, the outcome and the reward.
feedback
feedback(router_id: str, *, decision_id: str, reward: float, label: str | None = None) -> RouterFeedbackResult
Score a routed response (routers whose reward is feedback).
Parameters
router_id(str): Router id.decision_id(str):response.router_decision.idof the routed response.reward(float): From 0 (bad) to 1 (good). One reward per decision.label(str | None, optional): Optional note kept with the feedback.
remove_member
remove_member(router_id: str, member_id: str) -> None
Remove a member model from a router. Raises on failure; returns nothing.
stats
stats(router_id: str, *, period_hours: int = 24) -> RouterStats
Return what the router did in the last period_hours and what it has learned.
Per member: decisions, share, answered / failed, latency, cost, rewards; pulls and average reward over its whole life.