Shader
Agent keys and caps

DocsConcepts9 of 35 · 2 min read

Agent keys and caps

A spending permission a wallet gives one program, with a per-request cap and a per-day cap the program enforces on every charge.

An agent key lets a program spend from a wallet's credits without the wallet. It is an AgentKey account on chain, created and owned by the wallet, with two caps. An API token, shdr_ followed by 32 random bytes in base58, is bound to it; the agent sends it as a bearer token, and Shader keeps only its hash.

An agent key
  1. Createwallet signs
  2. AgentKeyper-request and per-day caps
  3. Tokenshown once
  4. SpendMCP, CLI, SDK
  5. Revokecloses the key

#The two caps

Per-request cap. The most credits one job may cost. A generation is checked against its estimate before it starts. A rental is checked at launch against its rate times 3,600 seconds of running, the longest an agent rental runs, so the cap must be at least the GPU's Credits/s times 3,600.

Per-day cap. The most credits the key may be charged in one UTC day. The day starts at 00:00 UTC, and the key's spend resets then. A launch or a generation that would take the key past what is left of the day, counting work not yet settled, is refused before it starts.

#Where the caps are enforced

The API refuses a launch or a generation over a cap with AGENT_CAP_EXCEEDED or AGENT_DAILY_CAP_EXCEEDED, before anything starts.

While an agent rental runs, it settles every 60 seconds like any other, and each settlement line names the key. Before each settlement the backend checks it against both caps and stops the rental first if it would pass one, so the rental ends inside the caps.

The program checks the same caps on every settlement line. If a line breaks one, the whole settle transaction fails with PerRequestCapExceeded or PerDayCapExceeded and none of its seconds are charged; the rental stops at once, and its page says the key's cap ended it.

#What a token can do

An agent token canOnly the wallet can
Launch, read, connect to and stop its rentalsAdd credits
Estimate, run and read generationsCreate, change and revoke keys
Read the balance, receipts, keys, Earn and transaction statusStake, withdraw and claim in Earn
Call the MCP serverSubmit signed transactions

Routes in the right column answer an agent token with UNAUTHORIZED. An agent sees the SSH and Jupyter details only of rentals launched under its own key.

#Revoking

revoke_agent_key is permanent. Every later charge through the key is refused, and the key stays on chain with its history, so its receipts still name it. Create an agent key covers creating, changing and revoking.