Skip to content

Routing

Install

Terminal window
pip install briefcase-ai

Quick Example

from briefcase import capture
from 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

OptionDefaultDescription
fallback_modelNoneModel to use when no route matches
load_balanceFalseDistribute across multiple providers