Platform Integrations
Pick your platform
Click any platform to see exact setup steps and a runnable code snippet.
Loading…
Examples
Full quickstart code
End-to-end workflows — read balance, send one payment, fetch the receipt. Works against the seeded sandbox out of the box.
"use strict";
const {
AgentPayClient,
buildDefaultAgentPayTools,
createGenericToolRegistry,
} = require("../../sdk/js");
function requireEnv(name) {
const value = String(process.env[name] || "").trim();
if (!value) {
throw new Error(`Missing required environment variable: ${name}`);
}
return value;
}
async function main() {
const baseUrl = requireEnv("AGENTPAY_BASE_URL");
const bootstrap = new AgentPayClient({ baseUrl });
const created = await bootstrap.registerAgent({
name: process.env.AGENTPAY_AGENT_NAME || "ResearchOpsAgent",
operator: process.env.AGENTPAY_OPERATOR || "local-dev",
metadata: {
source: "examples/js-agent/quickstart-workflow.js",
qa: true,
},
});
const client = new AgentPayClient({
baseUrl,
apiKey: created.api_key,
});
await client.fundWallet(created.wallet_id, {
amount: Number(process.env.AGENTPAY_FUND_AMOUNT || 25),
source: "test_faucet",
});
const tools = buildDefaultAgentPayTools();
const registry = createGenericToolRegistry(tools);
const balance = await registry.invoke(
"agentpay_get_balance",
{ wallet_id: created.wallet_id },
{ client }
);
const payment = await registry.invoke(
"agentpay_create_payment",
{
from_wallet_id: created.wallet_id,
to_external: process.env.AGENTPAY_DESTINATION || "merchant:test",
amount: Number(process.env.AGENTPAY_PAYMENT_AMOUNT || 5),
description: "JS quickstart payment",
},
{
client,
policy: {
maxPaymentAmount: Number(process.env.AGENTPAY_MAX_PAYMENT || 10),
allowedRails: ["internal"],
},
}
);
const inspected = await registry.invoke(
"agentpay_get_payment",
{ payment_id: payment.data.id },
{ client }
);
console.log(JSON.stringify({
agent: {
id: created.id,
wallet_id: created.wallet_id,
},
balance: balance.data,
payment: payment.data,
inspected: inspected.data,
}, null, 2));
}
if (require.main === module) {
main().catch((err) => {
console.error(err);
process.exit(1);
});
}
import json
import os
from agentpay_client import AgentPayClient
def require_env(name):
value = os.environ.get(name, "").strip()
if not value:
raise RuntimeError(f"Missing required environment variable: {name}")
return value
def main():
base_url = require_env("AGENTPAY_BASE_URL")
bootstrap = AgentPayClient(base_url)
created = bootstrap.register_agent({
"name": os.environ.get("AGENTPAY_AGENT_NAME", "PythonOpsAgent"),
"operator": os.environ.get("AGENTPAY_OPERATOR", "local-dev"),
"metadata": {
"source": "examples/python_agent/quickstart_workflow.py",
"qa": True,
},
})
client = AgentPayClient(base_url, api_key=created["api_key"])
client.fund_wallet(created["wallet_id"], {
"amount": float(os.environ.get("AGENTPAY_FUND_AMOUNT", "25")),
"source": "test_faucet",
})
balance = client.get_wallet_balance(created["wallet_id"])
payment = client.create_payment({
"from_wallet_id": created["wallet_id"],
"to_external": os.environ.get("AGENTPAY_DESTINATION", "merchant:test"),
"amount": float(os.environ.get("AGENTPAY_PAYMENT_AMOUNT", "5")),
"description": "Python quickstart payment",
})
inspected = client.get_payment(payment["id"])
print(json.dumps({
"agent": {
"id": created["id"],
"wallet_id": created["wallet_id"],
},
"balance": balance,
"payment": payment,
"inspected": inspected,
}, indent=2))
if __name__ == "__main__":
main()
OpenAI and Claude runtimes: build tools once from
buildDefaultAgentPayTools(),
expose them to the model, and execute them server-side through the adapters in sdk/js/adapters/.
For Python, wrap the client in your own tool executor.
JS files
sdk/js/client.js— HTTP client: agents, wallets, payments, x402, webhookssdk/js/tools.js— tool registry and default payment toolssdk/js/adapters/openai.js— OpenAI tool definitions + executorsdk/js/adapters/anthropic.js— Anthropic tool format + executorexamples/js-agent/quickstart-workflow.js— full workflowscripts/demo-client.js— seeded 3-call proof path
Python files
examples/python_agent/agentpay_client.py— stdlib client usingurllibexamples/python_agent/quickstart_workflow.py— full workflowdocs/AI_AGENT_INTEGRATION.md— integration guidescripts/seed.js— creates the seeded shopper + merchant
Testing
Integration checklist
Follow this order across all runtimes before adding mandates, A2A flows, or sandbox sharing.
Start from the seeded shopper and merchant. Verify the shopper wallet balance is visible before payment.
Run one small internal payment and confirm the returned
id is enough to fetch the receipt again.
Only after the proof path works, add mandates, A2A messages, and sandbox sharing for broader agent flows.
Set approval limits, rail allowlists, and payee restrictions in the runtime policy layer — not in the prompt alone.
To accept payments as a provider, register your service via
POST /v1/services and implement the x402 token verify and lifecycle endpoints (call-started, call-completed) before going live. The SLA clock starts on call-started — missing call-completed triggers an auto-refund.
Configure a payout destination (
bank, crypto, or stripe) via POST /v1/payouts so settled funds have a confirmed destination before your first live service call.
Subscribe to
payment.disputed webhook events and surface dispute status to operators — unresolved disputes block settlement for the affected payment and can affect the service trust_score.