Integrating with Kizuna: Developer Quick Start
Step-by-step developer guide to integrating with Kizuna. SDK setup, Meishi passport creation, choosing a payment lane, x402 endpoint configuration, and Companion API usage.
Quick Start
This guide walks through integrating Kizuna into your AI agent application. By the end, your agent will be able to verify payment approvals and settle transactions through the x402 facilitator.
Prerequisites
A KAMIYO API key (get one at app.kamiyo.ai), Node.js 18+, and a Solana wallet for your agent.
Install the SDK
npm install @kamiyo/x402-clientThe @kamiyo/x402-client package is the primary integration point. It wraps the x402 verify/settle endpoints with TypeScript types, retry logic, and error classification.
Initialize the Client
import { KizunaClient } from '@kamiyo/x402-client'
const client = new KizunaClient({
endpoint: 'https://x402.kamiyo.ai',
apiKey: process.env.KAMIYO_API_KEY,
})The client handles authentication, request signing, and connection management. Pass your API key via environment variable — never hardcode it.
Verify a Payment
Before your agent can make a payment, it must verify the request through Kizuna:
const approval = await client.verify({
amount: 100_000_000, // lamports
lane: 'enterprise', // or 'crypto-fast'
mandate: 'mandate_abc123', // enterprise: mandate ID
// collateral: 'pool_xyz', // crypto-fast: pool ID
})
if (approval.status === 'approved') {
console.log('Reservation:', approval.reservationId)
console.log('Expires:', approval.expiresAt)
} else {
console.log('Denied:', approval.reason)
}The verify response includes a reservation ID (for approved requests) or a denial reason. Reservations expire — settle them promptly.
Settle the Payment
const receipt = await client.settle(approval.reservationId)
console.log('Transaction:', receipt.txSignature)
console.log('Billable event:', receipt.eventId)Settlement is atomic — it either completes fully or fails entirely. The receipt includes the on-chain transaction signature and billable event ID for your records.
Framework Integrations
Kizuna provides framework-specific packages for popular AI agent toolkits:
Claude Agent SDK
@kamiyo/agents — Wraps Kizuna as a tool that Claude agents can invoke for payment operations. Drop-in integration with Anthropic's agent framework.Model Context Protocol
@kamiyo/mcp — MCP server that exposes Kizuna verify/settle as MCP tools. Any MCP-compatible agent can use Kizuna through standard tool calling.LangChain
@kamiyo/langchain — LangChain tool wrapper for Kizuna operations. Integrates with LangChain's agent and chain abstractions.Vercel AI SDK
@kamiyo/vercel-ai — Tool definitions for the Vercel AI SDK. Use with Next.js API routes and edge functions.Error Handling
The SDK classifies errors into actionable categories:
InsufficientFunds— mandate balance or collateral too low. Replenish and retry.PolicyDenied— kernel policy check failed. Check mandate limits and counterparty allowlists.ReservationExpired— too long between verify and settle. Re-verify and settle promptly.NetworkError— transient connectivity issue. SDK retries automatically with backoff.InvalidRequest— malformed request. Check parameter types and required fields.
Next Steps
- Enterprise Lane guide — Configure mandates and prefunding
- Crypto-Fast Lane guide — Set up collateral and pool management
- Financial Safety — Understand safety controls and kill switches
- x402 Protocol — Deep dive into the protocol specification
- Full Documentation — Complete API reference and guides
Frequently Asked Questions
How long does Kizuna integration take?
A basic integration can be completed in under an hour using the Kizuna SDK. Create a Meishi passport, fund your chosen lane (Enterprise mandate or Crypto-Fast collateral), configure x402 endpoints, and start settling. The SDK handles Kernel interaction, policy evaluation, and settlement execution.
Which payment lane should I choose?
Choose the Enterprise lane if you are a business running agent fleets with predictable budgets — prefunded mandates give you spending controls and audit trails. Choose Crypto-Fast if you are a crypto-native agent needing instant settlement with collateral you already hold. You can use both lanes simultaneously.
Can I test on devnet before mainnet?
Yes. Kizuna provides a full devnet deployment with test tokens. You can create test Meishi passports, fund test mandates or collateral positions, and simulate the complete Onboard → Verify → Settle → Repay flow without any real funds at risk.
Build with Kizuna
Start building with the trust, settlement, and control layer for agent commerce.
