Skip to main content

Crate agent_proxy_rust_model_router

Crate agent_proxy_rust_model_router 

Source
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§

ChannelState
Runtime health state for a channel, tracked in-memory.
ModelRouterMiddleware
Channel selection and model routing middleware.
PricingTier
A single tier in a Pricing::Tiered schedule.
QuotaUsage
Per-mapping monthly quota consumption tracker.
ResolvedChannel
Parsed in-memory representation of a channel with its model mappings.
ResolvedMapping
Parsed in-memory representation of a model mapping.
SelectedMappingInfo
Lightweight mapping info stored in the context extension.

Enums§

BillingDimension
The billing dimension for metered and tiered pricing.
ChannelBilling
Billing mode for a channel mapping.
ChannelHealth
Binary health status for a channel.
ExhaustedAction
Action when a flat-fee channel’s quota is exhausted.
Pricing
Pricing formulas for cost calculation.
Quota
Usage quota for a flat-fee channel.
TierPrice
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.