> ## Documentation Index
> Fetch the complete documentation index at: https://docs.key0.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Sell Anything to AI Agents

> Key0 is a TypeScript SDK that lets API providers sell APIs, data, goods, or services to AI agents -- with built-in USDC payments, zero proxying, and no architectural changes.

<img className="block dark:hidden" src="https://mintcdn.com/riklrinc/a8X0LipxzwlfUDpc/images/logo-light.png?fit=max&auto=format&n=a8X0LipxzwlfUDpc&q=85&s=9a61d447040e7676f423f01b93782181" alt="Key0" style={{ maxWidth: "200px" }} width="873" height="378" data-path="images/logo-light.png" />

<img className="hidden dark:block" src="https://mintcdn.com/riklrinc/a8X0LipxzwlfUDpc/images/logo-dark.png?fit=max&auto=format&n=a8X0LipxzwlfUDpc&q=85&s=3bc5ae8e0c1f6417cfec79eb31da361c" alt="Key0" style={{ maxWidth: "200px" }} width="873" height="378" data-path="images/logo-dark.png" />

Key0 is a TypeScript SDK that turns any API into a paid, agent-accessible service. Drop it into your Express, Hono, Fastify, or MCP server — agents discover your pricing, pay in USDC on Base via the x402 protocol, and get access. No signup walls, no API key portals, no proxying.

```bash theme={null}
npm install @key0ai/key0
```

## How it works in 30 seconds

<Steps>
  <Step title="Agent discovers your service">
    The agent calls `GET /discover` to browse your pricing plans — plan IDs, USDC amounts, and your wallet address. No payment yet.
  </Step>

  <Step title="Agent pays on-chain">
    The agent signs an EIP-3009 authorization off-chain (no gas required on their side). Key0's gas wallet executes the USDC transfer on Base.
  </Step>

  <Step title="Agent receives access">
    **Subscription plans:** Key0 returns a signed JWT (`AccessGrant`). The agent uses it as a Bearer token to call your protected endpoints.

    **Per-request plans:** Key0 returns the API response directly (`ResourceResponse`) — no token issued, payment settled per call.
  </Step>
</Steps>

<Note>
  Unfamiliar with terms like EIP-3009, x402, AccessGrant, or ChallengeEngine? Read [Core Concepts](/introduction/core-concepts) for plain-English definitions before continuing.
</Note>

***

## Why Key0

AI agents cannot fill out signup forms, enter credit cards, or navigate dashboards to get API keys. They need a **machine-native** way to discover, pay for, and access services.

Key0 solves this by embedding the entire payment-and-access flow directly into your API:

1. An agent discovers your service and its pricing (via A2A agent card or MCP tool).
2. It pays on-chain in USDC — one transaction, no intermediary.
3. It receives a signed JWT and calls your protected endpoints.

No proxy sits between the agent and your API. You keep full control of your infrastructure.

## Value props

<CardGroup cols={3}>
  <Card title="No Signup Walls" icon="server">
    Agents discover your service and pay automatically — no API key portals, no signup forms, no human in the loop.
  </Card>

  <Card title="Open Source & Self-Hostable" icon="code">
    Every part of the payment flow is auditable and customizable. Run it as an npm package embedded in your app, or as a standalone Docker container from `key0ai/key0` on Docker Hub.
  </Card>

  <Card title="Automatic Refunds" icon="rotate-left">
    If credential delivery fails after payment, Key0 settles a refund on-chain automatically. No manual intervention required.
  </Card>
</CardGroup>

## Supported agent environments

Key0 works with any agent that can make HTTP requests. It has been tested with:

* **Claude Code** — Anthropic's CLI agent
* **OpenClaw** — open-source agent framework
* **Cursor** — AI-powered IDE

## Protocols

<CardGroup cols={3}>
  <Card title="HTTP / REST" icon="globe" href="/protocol/x402-http-flow">
    Standard x402 payment flow over HTTP. Any HTTP client can participate.
  </Card>

  <Card title="MCP" icon="plug" href="/protocol/mcp">
    Model Context Protocol integration. Agents discover plans and pay via MCP tools
    over Streamable HTTP transport.
  </Card>

  <Card title="A2A" icon="arrows-left-right" href="/protocol/a2a-flow">
    Google's Agent-to-Agent protocol. A2A task lifecycle with x402 payment
    metadata built in.
  </Card>
</CardGroup>

## Payment rails

<Info>
  **Today:** USDC on Base (mainnet and Base Sepolia testnet) via the x402 protocol. On-chain, instant, non-custodial.
</Info>

<Note>
  **Coming soon:** Visa, Mastercard, and UPI support — so agents can pay with traditional rails when on-chain is not an option.
</Note>

## Install

<CodeGroup>
  ```bash npm theme={null}
  npm install @key0ai/key0
  ```

  ```bash pnpm theme={null}
  pnpm add @key0ai/key0
  ```

  ```bash bun theme={null}
  bun add @key0ai/key0
  ```

  ```bash Docker theme={null}
  docker pull key0ai/key0
  ```
</CodeGroup>

## Next steps

<CardGroup cols={2}>
  <Card title="Quickstart: Embedded" icon="bolt" href="/quickstart/embedded">
    Add Key0 to an existing Express, Hono, or Fastify server in under 5 minutes.
  </Card>

  <Card title="Quickstart: Standalone" icon="docker" href="/quickstart/standalone">
    Run Key0 as a standalone Docker service that sits alongside your API.
  </Card>

  <Card title="Core Concepts" icon="book" href="/introduction/core-concepts">
    Plain-English definitions of every Key0 term — read this before diving in.
  </Card>

  <Card title="Paying for Access" icon="credit-card" href="/guides/paying-for-access">
    For agents and buyers: how to discover, pay, and call a Key0-protected API.
  </Card>
</CardGroup>
