Create an agent key
Give a program its own token to spend your credits, with the caps you choose, and change or revoke it later.
An agent key is created, changed and revoked by your wallet's signature, so these steps are in the app. You need a connected, signed-in wallet with some SOL for the transaction fee and the key account's rent.
#Create the key
Name it and set the caps
Open Agents and, under New key, give the key a Name of up to 32 bytes. Set Per-request cap, credits and Per-day cap, credits. For an agent that rents, the per-request cap must cover the GPU's rate for 3,600 seconds: the Credits/s that GPUs shows, times 3,600.
Sign
Press Create a key and approve the
create_agent_keytransaction in your wallet. The key exists once it confirms.Copy the token
The token appears once, right after the key is created. Copy it into the agent's environment before you press Done. Shader keeps only its hash, so a lost token means a new key.
#What happened
Build
The API built the
create_agent_keytransaction with a fresh 32-byte key id.Sign and relay
Your wallet signed it and the API relayed it.
On chain
The program created the
AgentKeyaccount with your caps.The token
The first read of the confirmed transaction returned the token,
shdr_followed by 32 random bytes in base58. Later reads never return it.
#Afterwards
The agent sends the token as a bearer token, through the MCP server, the CLI, the SDK or the API:
curl $SHADER_API/credits/balance -H "authorization: Bearer $SHADER_TOKEN"On Agents each key shows its caps and what it Spent today, and Receipts for this key opens everything it was charged. To change the caps, edit them and sign update_agent_key. Revoke signs revoke_agent_key, which is permanent: every later charge through the key is refused, and its receipts still name it.
#If it fails
| What you see | Why | Next |
|---|---|---|
WALLET_REJECTED | You declined in the wallet | Sign again |
VALIDATION_ERROR | An empty name, a name over 64 characters, or a cap of 0 | Fix the field |
SIMULATION_FAILED naming InvalidLabel | The name is over 32 bytes | Use a shorter name |
UNAUTHORIZED | The request used an agent token; keys need the wallet | Sign in with the wallet |
AGENT_KEY_REVOKED on a change | The key is revoked | Create a new key |