Agents
Install the agent skill
The skill teaches an agent the x402 loop: list paid routes, read the challenge, ask you, pay, replay. It works in Claude Code, Cursor and any runtime that loads SKILL.md files.
Install
git clone https://git.tollgate402.com/tollgate/gateway.git tollgate
mkdir -p .claude/skills/tollgate-x402
cp tollgate/skill/SKILL.md .claude/skills/tollgate-x402/
echo "TOLLGATE_URL=https://gateway.tollgate402.com" >> .envRestart the agent session. The skill registers three tools and stays dormant until a task mentions a paid API or a request returns 402.
Tools the agent gets
| Tool | What it does | Spends? |
|---|---|---|
x402_discover | Reads /.well-known/x402 and returns routes, prices and session terms | No |
x402_quote | Calls a route without payment and parses the 402 challenge | No |
x402_pay | Signs the PaymentIntent after approval, settles and replays | Yes, capped |
Approval and spend caps
x402_pay never runs silently. The agent shows the route, price and expiry and waits for an explicit yes. You can pre-approve small amounts per session:
# approve automatically up to this much per session
TOLLGATE_AUTO_APPROVE_MAX=0.05
# hard cap per day, enforced by the gateway too
TOLLGATE_DAILY_CAP=5.00
TOLLGATE_API_KEY=tg_live_3f9a1c07e2b84d6a59c1e0f7ab42A typical exchange
- You ask for a pre-market brief. The agent calls
x402_discoverand finds /x402/premium at 0.01 USDG. - It calls
x402_quote, gets the challenge and asks: “Pay 0.01 USDG for /x402/premium?” - You approve.
x402_paysettles on Robinhood Chain and returns the payload plus the tx hash.