Expand description
Model routing and channel selection middleware.
Implements the selection strategy from specs/0003-channel-model.md Phase 1:
FlatFee channels with quota > 0 and healthy are preferred; Metered channels
serve as fallback. Health tracking uses a simple binary model with 60s
cooldown.
Structs§
- Channel
State - Runtime health state for a channel, tracked in-memory.
- Model
Router Middleware - Channel selection and model routing middleware.
- Pricing
Tier - A single tier in a
Pricing::Tieredschedule. - Quota
Usage - Per-mapping monthly quota consumption tracker.
- Resolved
Channel - Parsed in-memory representation of a channel with its model mappings.
- Resolved
Mapping - Parsed in-memory representation of a model mapping.
- Selected
Mapping Info - Lightweight mapping info stored in the context extension.
Enums§
- Billing
Dimension - The billing dimension for metered and tiered pricing.
- Channel
Billing - Billing mode for a channel mapping.
- Channel
Health - Binary health status for a channel.
- Exhausted
Action - Action when a flat-fee channel’s quota is exhausted.
- Pricing
- Pricing formulas for cost calculation.
- Quota
- Usage quota for a flat-fee channel.
- Tier
Price - Per-unit price within a tier, discriminated by dimension type.
Functions§
- reload_
channels_ from_ storage - Hot-reloads the in-memory channel list from storage and atomically swaps
it into
channels_swap.