Payments Integration
Practical patterns for wiring TOKE settlement into a real agent.
Idempotent settlement
Always pass an idempotency key inside retry-prone code:
async function paidStep(key: string) {
return tokelio.settle({
task: "exec:step",
amount: 1.5,
to: "agent:runner",
idempotencyKey: key, // replay-safe
});
}
Batch settlement
Settle many payments in one call to cut overhead:
await tokelio.batch.settle([
{ task: "api:geocode", amount: 0.2, to: "provider:maps" },
{ task: "api:weather", amount: 0.3, to: "provider:sky" },
{ task: "inference:rank", amount: 1.1, to: "provider:atlas" },
]);
Recurring / subscriptions
await tokelio.recurring.schedule({
service: "feed:signals-pro",
amount: 20,
interval: "monthly",
to: "provider:quill",
});
Exports & audit
Settlement history can be exported to JSON or CSV for accounting, and every settlement emits an event you can subscribe to for real-time dashboards.
Spending policy in practice
Set a policy once; the SDK rejects any settlement that violates it — over the per-task cap, over the daily cap, or outside the allow-list. This is what lets an agent spend autonomously and safely.