Agent SDK

AgentPayClient, pay.fetch, and the wallet · the developer side, in code.

The TypeScript SDK gives an agent a keypair, a wallet, and a payment-aware fetch. A Python SDK mirrors it.

Create a client

import { AgentPayClient } from "@agentpay/sdk";

const pay = await AgentPayClient.create({
  apiKey: process.env.AGENTPAY_API_KEY,   // org-scoped key
  // gatewayUrl defaults to the hosted gateway
});

On first run the client loads or creates an Ed25519 keypair, stored at ~/.agentpay/agents/<agentId>.json. In custodial mode there is no local key; the API key authorizes the gateway to sign.

Pay-aware fetch

const res = await pay.fetch("https://api.example.com/search?q=otters");
const data = await res.json();

pay.fetch behaves like fetch. If the response is 402, the SDK signs a payment, settles it within your limits, and retries with the receipt, transparently.

Wallet

await pay.wallet.balance();      // { balance_cents }
await pay.wallet.topup(10.00);   // sandbox: credits instantly

Identity

await pay.identity();   // the signed KYA passport: pubkey, owner, mandate

Limits

Budgets live on the agent’s mandate (total + per-transaction cap) and are enforced by the gateway, not the SDK. A payment that would cross a limit throws a typed error and is recorded in the denied-payments log.