> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Spend Budget Policy Protocol • AI Agent SDK

> SpendBudgetPolicyProtocol: Protocol for gateway cumulative-spend admission decisions.

# SpendBudgetPolicyProtocol

> Defined in the [**protocols**](../modules/protocols) module.

<Badge color="blue">AI Agent</Badge>

Protocol for gateway cumulative-spend admission decisions.

Pure, import-free decision contract symmetric with
:class:`RateLimitPolicyProtocol`. The wrapper supplies typed facts — the
caller `identity`, the `scope` (channel / tenant token), the amount
already `spent_usd` for that identity+scope in the current window, the
current `now` timestamp, and (optionally) the `pending_usd` estimated
cost of the turn being admitted and the `oldest_spend_ts` of the spend in
the window — and the policy decides whether the turn is allowed or
rejected/throttled with a `retry_after_seconds` hint. Storage of the
spend ledger lives in a
:class:`~praisonaiagents.telemetry.protocols.TokenUsageSinkProtocol`; this
contract keeps only the *decision* injectable and provable in isolation.

A config-driven default (:class:`WindowedSpendBudgetPolicy`) is provided
for the common "cap \$X per identity per rolling window" case.

## Methods

<CardGroup cols={2}>
  <Card title="check()" icon="function" href="../functions/SpendBudgetPolicyProtocol-check">
    Return a :class:`RateLimitDecision` for the supplied facts.
  </Card>
</CardGroup>

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/gateway/protocols.py#L4336">
  `praisonaiagents/gateway/protocols.py` at line 4336
</Card>
