Routing
Install
pip install briefcase-aiQuick Example
from briefcase import capturefrom briefcase.routing import Router
router = Router()router.add_route("summarize", model="gpt-4o-mini")router.add_route("analyze", model="claude-sonnet-4-6-20250514")
@capture()def process(task_type: str, text: str) -> str: model = router.resolve(task_type) return model.complete(text)Architecture
The router maps task types to model configurations. All routing decisions are captured in the snapshot metadata, enabling analysis of which models serve which tasks.
flowchart LR
A["Request"] --> B["Router"]
B --> C{"task type?"}
C -- summarize --> D["gpt-4o-mini"]
C -- analyze --> E["claude-sonnet"]
C -- no match --> F["fallback model"]
D & E & F --> G["capture decorator"]
G --> H["DecisionSnapshot"]
Key Classes
Router— maps task types to model configurations
Configuration
| Option | Default | Description |
|---|---|---|
fallback_model | None | Model to use when no route matches |
load_balance | False | Distribute across multiple providers |