@agentcash/router · Vercel template

Fortune Demo

A pay-per-call API on x402 and MPP, deployed live at https://agentcash-fortune-demo3.vercel.app.

Try it

The fastest path is the AgentCash CLI — a single wallet, no API keys, all endpoints work out of the box.

npx agentcash fetch https://agentcash-fortune-demo3.vercel.app/api/fortune --method POST -p x402

Or with curl — the router returns an HTTP 402 challenge you can settle manually:

curl -X POST https://agentcash-fortune-demo3.vercel.app/api/fortune

Endpoints

Every route demonstrates a different @agentcash/router pricing or auth mode. Source: app/api/fortune/.

POST/api/fortune.paid("0.001")

Fixed-price fortune. x402 exact (Base) or MPP one-shot (Tempo).

npx agentcash fetch https://agentcash-fortune-demo3.vercel.app/api/fortune --method POST -p x402
POST/api/fortune/premium.upTo("0.005")

Handler-driven metered pricing settled with EIP-2612 gas-sponsoring on Base.

npx agentcash fetch https://agentcash-fortune-demo3.vercel.app/api/fortune/premium --method POST -p x402 -b '{"category":"love"}'
POST/api/fortune/llm.metered({ unitType: "request" })

MPP session, request-mode metered billing. Returns 503 until MPP_OPERATOR_KEY is set.

npx agentcash fetch https://agentcash-fortune-demo3.vercel.app/api/fortune/llm --method POST -p mpp -b '{"prompt":"Will I find love?"}'
POST/api/fortune/stream.metered({ unitType: "token" }).stream()

MPP session, SSE streaming with per-token billing. Returns 503 until MPP_OPERATOR_KEY is set.

npx agentcash fetch https://agentcash-fortune-demo3.vercel.app/api/fortune/stream --method POST --stream -b '{"prompt":"What awaits me?"}'
POST/api/fortune/dynamic.paid(pricingFn)

Body-derived pricing with pre-payment validation.

npx agentcash fetch https://agentcash-fortune-demo3.vercel.app/api/fortune/dynamic --method POST -b '{"category":"love","depth":"detailed"}'
POST/api/fortune/membership.upTo("0.005").siwx()

Pay once via x402; subsequent calls replay free with a SIWX signature.

npx agentcash fetch https://agentcash-fortune-demo3.vercel.app/api/fortune/membership --method POST -p x402
GET/api/fortune/profile.siwx()

Verified wallet identity, no payment.

npx agentcash fetch https://agentcash-fortune-demo3.vercel.app/api/fortune/profile --method GET
POST/api/fortune/favorites.siwx()

Save a favorite fortune (SIWX, no payment).

npx agentcash fetch https://agentcash-fortune-demo3.vercel.app/api/fortune/favorites --method POST -b '{"fortune":"A good day awaits"}'

Discovery

Agents discover this API by reading /openapi.json. The router emits an OpenAPI 3.x spec annotated with AgentCash pricing and auth extensions — drop it in agentcash discover or any compatible crawler.

/openapi.jsonAgentCash Discovery — OpenAPI 3.x with pricing extensions.
/llms.txtAgent-readable usage guidance.

Customize

  1. Edit app/api/fortune/* to replace the demo handlers with your real endpoints.
  2. Update lib/router.ts with your API title, description, and agent-guidance string.
  3. Push to GitHub. Vercel redeploys automatically.

Full docs: agentcash.dev/docs · github.com/Merit-Systems/agentcash-router