@key0ai/key0/hono:
key0App(opts)— a Hono sub-app that serves agent discovery and the x402 payment endpoint.honoValidateAccessToken({ secret })— middleware that validates Bearer JWTs issued by Key0.
Installation
Routes
When you mountkey0App, the following routes are registered:
Setup
1
Configure the seller
Define your
SellerConfig with wallet address, network, agent identity, and pricing plans.2
Create stores and adapter
Provide the required
IChallengeStore, ISeenTxStore, and IPaymentAdapter instances.3
Mount the sub-app
Import Your agent card is now available at
key0App from @key0ai/key0/hono and mount it on your main Hono app.GET /.well-known/agent.json and the payment endpoint at POST /x402/access.4
Protect routes with access token validation
Use
honoValidateAccessToken as middleware on any route that requires a valid Key0 JWT.Accessing the decoded token
AfterhonoValidateAccessToken succeeds, the decoded JWT payload is available via c.get("key0Token"). The payload contains:
On failure, the middleware returns a JSON error response:
Full example
API reference
key0App(opts)
Creates a Hono sub-app with agent card discovery and the x402 payment endpoint.
honoValidateAccessToken(config)
Returns Hono middleware that validates a Bearer token from the Authorization header.
Pay-Per-Request Routes
key0App returns the Hono app and a payPerRequest(routeId, opts?) factory. Use it as Hono middleware on individual routes to gate them behind micro-payments — no JWT issued, payment settles inline.
PAYMENT-SIGNATURE header the middleware returns 402 with x402 payment requirements. After settlement, the PaymentInfo is available via c.get("key0Payment").
For standalone gateway mode, add proxyTo to SellerConfig — see the Express integration for the full proxy configuration reference.
Next Steps
SellerConfig Reference
Complete reference for every configuration option.
Paying for Access
How clients discover, pay, and call your protected endpoints.
Express Integration
Full A2A JSON-RPC support is available on Express only.
x402 HTTP Flow
Full protocol reference for the payment flow.

