Choose the right control
| Need | Use | Behavior |
|---|---|---|
| Know when spend crosses a line | Cost threshold | Post-call alert after usage is recorded. |
| Warn on budget risk | Budget limit warn | The call proceeds, and Pylva records or alerts on spend. |
| Cap customer usage | Budget limit hard stop | The SDK blocks before the provider call when an active cached rule applies. |
| Steer a narrow model path | Model routing | Advanced pre-call model or provider steering. |
| Recover from provider trouble | Reliability failover | Advanced pre-call reliability control that requires explicit cost-shift consent. |
| Find margin risk | Margin protection | Scheduled analysis and recommendations. |
customer_throttle is not a supported public rule type.
Rollout path
- Confirm telemetry is trusted: customer, step, pricing, and dashboard events are visible.
- Start with alert-only rules or warn mode before hard stops.
- Use drafts for review before production activation.
- Activate narrow scopes first: one customer, one step, or one model path.
- Catch
PylvaBudgetExceededand return a product-specific fallback. - Monitor rule events, warnings, alerts, and budget behavior after activation.
- Expand scope only after the narrow rollout behaves as expected.
- Roll back by disabling the rule or moving it back to draft.
Pre-call and post-call
Pre-call controls can block or steer a call before provider spend happens. Budget hard stops, model routing, and reliability failover are pre-call controls. Post-call controls alert after usage is recorded. Cost thresholds and margin protection do not stop the provider call that already happened.Hard stops
Hard stops only block when the SDK has an active cached rule it can enforce safely. When a hard stop fires, the SDK raisesPylvaBudgetExceeded. Catch it and return a fallback such as a cached answer, smaller model path, queued job, “try again later” response, or human handoff.
Avoid retry loops that immediately reissue the same expensive call.