- A Stigg server API key.
- Governance enabled on your account.
- A credit currency
creditsand a customercustomer-acmewith a credit grant much larger than the team budget, so the denials come from the budgets and not from an empty wallet. See Set up credits.
1
Create the entity types
Create two entity types in your environment, once:
Do this in the Stigg app or through the API. See Setting up governance.
2
Create the team and its budget
Add the
team-research entity to customer-acme with an assignment of 8 credits per month (P1M). See Setting up governance.In a real product, your customer’s admin usually sets the team budget through an interface you build.3
Register the agents
Register each agent when it is created in your product.
register() creates the entity, places it under the team, and writes its budget.4
Wrap the client
- The usage mapper reports to
credits, the same currency the budgets are written against. Reporting raw token names here would not count against a credit budget. ingestMode: 'sync'updates the budgets with each call, so the next check sees the spend.- Governance counts agent usage in whole units, so the amount of each call made as an agent is rounded up to a whole credit. A call of 400 tokens costs 1 credit.
5
Run the agents and handle denied access
agentId with attributionKey attributes each check and report to that agent, so Governance checks the agent, the team and the customer together.Expected output, abbreviated:6
Respond to the right person
Use
deniedBy and remedy to decide how to respond:Raise a budget by calling
register() again with a new budget.limit, or in the Stigg app. Denials are never cached, so the next call goes through.7
See it in Stigg
Open
customer-acme in the Stigg app to see current usage and limits for the team and for each agent. To build the same view in your product, use the governance query API.Going to production
- Checks for an agent are never cached: each one asks Stigg, so a cap is enforced on the first call that exceeds it, even across several servers. See Caching and accuracy.
- Decide what a call should do when a check cannot complete, with
checkErrorAction. See Fallback strategy. - Start with
budget: { entitlement, limit: null }to observe usage per agent before you enforce. See Observe-only rollout.