# Per-feature budgets (/docs/recipes/per-feature-budgets)



Different features have different appetites. A background summarizer, a RAG search, an
interactive chat — you often want each on its own budget so a spike in one doesn't starve the
others. Tag each feature and give it its own limit.

## The rule [#the-rule]

Tag your calls with a `feature` label (below), then click **New rule from template** on the
Firewall page and pick one of these:

<Steps>
  <Step>
    **Give each team or feature its own budget** — set &#x2A;*Which tag?** to `feature` and every feature
    gets its own separate budget. Only the feature that overspends is paused.
  </Step>

  <Step>
    **Per-user limit for a feature** — if you'd rather cap each *user* inside one named feature. You
    name the feature and the per-user limit.
  </Step>
</Steps>

<Callout type="info">
  For the built-in split between chat and embedding calls you don't need a label at all — filter
  on `operation` **is** `embedding`. Custom labels are for splits TokenPolice can't infer, like
  "summarizer" vs "chat". See [Filter vs apply-to](/docs/rules/match-vs-groupby).
</Callout>

## The snippet [#the-snippet]

Give each feature its own workflow with a `feature` value in `metadata`:

```python
import token_police as tp

@tp.workflow(name="summarizer", metadata={"feature": "summarizer"})
def summarize(doc: str):
    return client.chat.completions.create(...)

@tp.workflow(name="chat", metadata={"feature": "chat"})
def chat(user_id: str, query: str):
    return client.chat.completions.create(...)
```

```typescript
import { workflow } from "token-police";

const summarize = workflow(
  { name: "summarizer", metadata: { feature: "summarizer" } },
  (doc: string) => client.chat.completions.create(/* ... */),
);
```

Every call inside `summarize` is tagged `feature=summarizer`, every call inside `chat` is
`feature=chat`, and the rule keeps their budgets apart. Tag values are matched exactly, so keep
the spelling stable — see [Identity](/docs/concepts/identity).

## Next [#next]

<Cards>
  <Card title="Multi-tenant budgets" href="/docs/recipes/multi-tenant-budgets" description="The same pattern, keyed by tenant." />

  <Card title="Wrapping your app" href="/docs/sdk/wrapping" description="workflow, session, agent, and chain." />
</Cards>
