Skip to content

Quickstart

In this guide you will install the agent SDK, create a client with your API key, and request your first metered payment.

terminal
# private beta package — invite required
npm i @allowkit/agent
# or: bun add @allowkit/agent · pnpm add @allowkit/agent
.env
ALLOWKIT_API_KEY=ak_live_...
ALLOWKIT_AGENT_ID=researchbot-01
agent.ts
import { AllowKit } from "@allowkit/agent";
const allowkit = new AllowKit({
apiKey: process.env.ALLOWKIT_API_KEY,
agentId: "researchbot-01"
});
// Request a metered payment. Resolves only if it passes
// the agent's allowance + policy checks.
const result = await allowkit.pay({
service: "risk-report-api",
amount: "0.03",
asset: "USDC",
reason: "Fetch risk report"
});
console.log(result.status); // "approved" | "blocked"

If the payment is within the agent’s daily budget, under the max-per-payment cap, and the service is approved, it settles in USDC on Solana. Otherwise it’s blocked and logged — your code receives status: "blocked" instead of an uncontrolled charge.

approved.json
{
"id": "pay_01JY6K6Y8F7P4B2S1Q8Z9R0M3N",
"status": "approved",
"amount": "0.03",
"asset": "USDC",
"service": "risk-report-api",
"tx": "5xL...9Qp",
"policyRevision": "polrev_18",
"spentToday": "1.45",
"createdAt": "2026-06-10T09:31:04Z"
}
blocked.json
{
"id": "pay_01JY6K7CMYV9J7R2BEED9F48A2",
"status": "blocked",
"reason": "service_not_approved",
"message": "risk-report-api is not approved for researchbot-01",
"policyRevision": "polrev_18"
}