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

# AgentCash Router

> An open-source TypeScript router for shipping pay-per-call APIs on x402 and MPP with minimal boilerplate.

We've tested tens of thousands of endpoints and found that the hand-rolled ones tend to break in the details, with malformed 402 challenges, network identifiers agents can't settle against, and missing discovery metadata. **The [`@agentcash/router`](https://github.com/merit-systems/agentcash-router) gets all of this right for you.**

The router is the fastest and most effective way to ship an API on x402 and MPP. Just define routes with a fluent builder, and the router handles payment challenges, verification, settlement, wallet identity, and discovery.

## What you get

**Every pricing model.** One route definition and support every pricing model across x402 and MPP.

```typescript theme={null}
router.route('search').paid('0.01').handler(run);                 // fixed price
router.route('research').upTo('0.05').handler(meter);             // billed as the handler works
router.route('llm').session({ unitCost: '0.0001' }).stream(gen);  // per-unit, SSE streaming
```

**[Discovery](/discovery) built in.** Your route definitions generate the documents that get you indexed by [x402scan](https://x402scan.com), [mppscan](https://mppscan.com), and [AgentCash](https://agentcash.dev), so agents can instantly find, understand, and call your API.

```text theme={null}
GET /openapi.json   → OpenAPI 3.1 with pricing extensions
GET /llms.txt       → plain-text guidance for agents
```

**Identity without accounts.** `.siwx()` verifies who's calling with a wallet signature, giving you per-user state with no signup flow or API keys.

```typescript theme={null}
router.route('inbox').siwx().handler(async ({ wallet }) => inboxFor(wallet));
router.route('report').paid('0.01').siwx().handler(fn);  // pay once, replay free
```

## Deploy in one click

The recommended way to start is the Vercel template: a working pay-per-call API that exercises every pricing mode.

<a style={{ display: "inline-block", width: "fit-content", textDecoration: "none", borderBottom: "none" }} href="https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2FMerit-Systems%2Fagentcash-router%2Ftree%2Fmain%2Fexamples%2Fvercel-deploy&project-name=agentcash-fortune-demo&repository-name=agentcash-fortune-demo&demo-title=AgentCash%20Router%20Fortune%20Demo&demo-description=Pay-per-call%20fortune%20API%20on%20x402%20and%20MPP&demo-url=https%3A%2F%2Fagentcash.dev&env=EVM_PAYEE_ADDRESS%2CCDP_API_KEY_ID%2CCDP_API_KEY_SECRET&envDescription=Wallet%20that%20receives%20payments%20%2B%20Coinbase%20Developer%20Platform%20API%20keys%20for%20the%20default%20x402%20facilitator.%20Create%20keys%20in%20the%20generous%20CDP%20free%20tier%3A%20https%3A%2F%2Fportal.cdp.coinbase.com%2Fprojects%2Fapi-keys&envLink=https%3A%2F%2Fgithub.com%2FMerit-Systems%2Fagentcash-router%2Fblob%2Fmain%2Fexamples%2Fvercel-deploy%2FREADME.md%23environment-variables">
  <img noZoom style={{ display: "block", margin: 0 }} alt="Deploy with Vercel" src="https://vercel.com/button" />
</a>

See the [quickstart](/router/quickstart) for the full walkthrough.

<CardGroup cols={2}>
  <Card icon="rocket" title="Quickstart" href="/router/quickstart">
    Deploy the template or add the router to an existing app.
  </Card>

  <Card icon="route" title="Routes and pricing" href="/router/routes">
    Every auth mode with examples.
  </Card>

  <Card icon="server" title="Hosting" href="/router/hosting">
    Next.js, Hono, Bun, Node, and discovery endpoints.
  </Card>

  <Card icon="settings" title="Configuration" href="/router/configuration">
    Environment variables, KV stores, and plugin hooks.
  </Card>
</CardGroup>
