Quickstart
This guide walks you through obtaining an API key, creating a wallet, and making a request with the AgentPay SDK. By the end you'll have a working integration that can pay 402-protected APIs automatically.
Prerequisites
- Node.js 18+ (for TypeScript) or Python 3.8+ (for Python).
- Access to the AgentPay API (e.g.
https://api.agentpay.solutionsor your self-hosted URL).
Step 1: Get an API key
The easiest way is to sign up at agentpay.solutions: sign in with GitHub, then copy your API key from the API Keys page. You can also create a key by calling the API directly (see below). The key is returned in plaintext only once; store it securely (e.g. in an environment variable).
curl -X POST https://api.agentpay.solutions/api-keys \
-H "Content-Type: application/json" \
-d '{"label":"my-agent"}'
# Response 201
# { "id": "...", "label": "my-agent", "key": "pk_..." }
# Save the "key" value; it is only returned once.
# If you get 503 or 400 "Failed to create API key", use the dashboard instead:
# https://agentpay.solutions/dashboard → sign in, then copy your key from API Keys.Step 2: Create a wallet
Wallets are scoped to your API key and to a network. Create one for Base so the API can satisfy 402 payments on that network.
curl -X POST https://api.agentpay.solutions/wallets \
-H "X-Api-Key: pk_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"network":"base"}'
# Response 201
# { "id": "...", "wallet_id": "...", "network": "base" }Step 3: Use the SDK
Install the TypeScript or Python SDK and use it like a normal HTTP client. When the upstream API returns 402, the SDK calls AgentPay to pay and retries with the payment signature automatically.
TypeScript
npm install @agentpay/sdk
import { createAgentPayClient } from "@agentpay/sdk";
const client = createAgentPayClient({
apiKey: process.env.AGENTPAY_API_KEY!,
baseUrl: "https://api.agentpay.solutions",
});
const res = await client.get("https://paid-api.example/resource");
// On 402: SDK calls POST /v1/pay, then retries with PAYMENT-SIGNATURE
const data = await res.json();Python
pip install agentpay
from agentpay import create_agent_pay_client
client = create_agent_pay_client(
api_key=os.environ["AGENTPAY_API_KEY"],
base_url="https://api.agentpay.solutions",
)
resp = client.get("https://paid-api.example/resource")
data = resp.json()Using the skill in an AI coding agent
If you use the AgentPay skill in Cursor, OpenCode, Windsurf, or another AI coding agent, you can create API keys and wallets the same way: the agent can call POST /api-keys and POST /wallets for you. Those keys work immediately but are "unclaimed" until you sign up at the dashboard and use Link existing key to attach them to your account. See Plans and limits for details.
Next steps
Read about Plans and limits (including unclaimed keys and link key), the 402 flow, the TypeScript SDK and Python SDK guides, and the API Reference.