- Accepts USDC payments from AI agents
- Either calls your
ISSUE_TOKEN_APIto fetch credentials (subscription plans), or proxies to your backend and returns data directly (pay-per-call routes) - Automatically refunds agents if your token endpoint fails or the backend returns an error
- Exposes
GET /discover,POST /x402/access, and the generated buyer-onboarding bundle
New to Key0? Read Core Concepts first to understand terms like Plan, Challenge, AccessGrant, and EIP-3009. See Two Modes to understand how Standalone differs from Embedded.
GET /.well-known/agent.jsonwhen A2A is enabledGET /.well-known/mcp.jsonandPOST /mcpwhen MCP is enabledGET /llms.txtGET /skills.md
buildCli(), and upload the output to your preferred host. See the Agent CLI guide for step-by-step instructions.
- Setup UI
- Environment Variables
Option A: Setup UI (zero-config start)
Start the container with no configuration. The Setup UI walks you through everything visually.Start the container
The Then start the services:
full profile starts Key0 with managed Redis and Postgres — batteries included.Download the Docker Compose file:Open the Setup UI
Navigate to http://localhost:3000. On first launch, you are redirected to
/setup.The Setup UI lets you configure:- Wallet address — the USDC-receiving address on Base
- Network — mainnet or Base Sepolia testnet
- Pricing plans — plan IDs, amounts, and descriptions
- Token issuance API — the URL Key0 calls after payment to fetch credentials
- Settlement and refund settings
Docker Compose profiles
Choose a profile based on what managed infrastructure you need:| Profile | What starts |
|---|---|
| (none) | Key0 only — bring your own Redis + Postgres via env vars |
--profile redis | Key0 + managed Redis |
--profile postgres | Key0 + managed Postgres (still needs Redis externally) |
--profile full | Key0 + managed Redis + managed Postgres (batteries included) |
ISSUE_TOKEN_API contract
After Key0 verifies an on-chain USDC payment, it POSTs to yourISSUE_TOKEN_API endpoint with the payment details:
Request body
If your
ISSUE_TOKEN_API endpoint returns an error or is unreachable, Key0 automatically initiates an on-chain refund to the paying agent. See Automatic Refunds for details.Pay-Per-Call Routes (PROXY_TO_BASE_URL)
For top-levelroutes, Key0 settles the payment and then proxies the request to your backend — no ISSUE_TOKEN_API call is made for these route purchases. The agent receives a ResourceResponse containing the backend’s actual response data.
PROXY_TO_BASE_URL to your backend’s base URL and add pay-per-call routes to ROUTES:
PROXY_TO_BASE_URL is set:
- Pay-per-call routes are handled by the proxy — agents call the route directly, Key0 settles and forwards to
PROXY_TO_BASE_URL + path. - Subscription plans still call
ISSUE_TOKEN_APIas normal. - Routes and plans can coexist in the same config.
| Header | Value |
|---|---|
x-key0-tx-hash | On-chain transaction hash |
x-key0-plan-id | Plan that was charged |
x-key0-amount | Dollar amount (e.g. "$0.01") |
x-key0-payer | Payer wallet address (when available) |
ISSUE_TOKEN_API is not called for pay-per-call routes when PROXY_TO_BASE_URL is set. You can omit it entirely if all you are selling is route access.Test it
Once the container is running, verify the setup:Check the agent card
Expected output
Browse available plans
Expected output
Request access to a plan (returns 402 challenge)
Expected output (HTTP 402)
planId. The access request returns an x402 challenge with the payment amount and destination wallet. An agent completes the flow by signing an EIP-3009 authorization and submitting proof. See Paying for Access for the full client walkthrough.
If you have pay-per-call routes configured (with PROXY_TO_BASE_URL), test the route flow by calling the route directly:
Request a paid route (returns 402 challenge)
Expected output (HTTP 402 — same as subscription)
ResourceResponse with your backend’s data instead of an AccessGrant. See Paying for Access — Per-Request Flow for the full client walkthrough.
Docker image tags
| Tag | When to use |
|---|---|
latest | Latest stable release |
1.2.3 / 1.2 / 1 | Specific version pinning for production |
canary | Latest main branch build (for testing) |
Next steps
Environment Variables
Full reference of all configuration options including PROXY_TO_BASE_URL.
Pay-Per-Request Standalone Example
Runnable example: Key0 as a payment gateway proxying to a backend API.
Storage Configuration
Redis, Postgres, and custom storage backends.
Automatic Refunds
How Key0 handles failed deliveries with on-chain refunds.

