Shader
Create an agent key

DocsGuides20 of 35 · 2 min read

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

  1. 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.

  2. Sign

    Press Create a key and approve the create_agent_key transaction in your wallet. The key exists once it confirms.

  3. 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

  1. Build

    The API built the create_agent_key transaction with a fresh 32-byte key id.

  2. Sign and relay

    Your wallet signed it and the API relayed it.

  3. On chain

    The program created the AgentKey account with your caps.

  4. 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:

Terminal
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 seeWhyNext
WALLET_REJECTEDYou declined in the walletSign again
VALIDATION_ERRORAn empty name, a name over 64 characters, or a cap of 0Fix the field
SIMULATION_FAILED naming InvalidLabelThe name is over 32 bytesUse a shorter name
UNAUTHORIZEDThe request used an agent token; keys need the walletSign in with the wallet
AGENT_KEY_REVOKED on a changeThe key is revokedCreate a new key