TypeScript runtime for machine commerce

Turn any TypeScript function into a paid API.

Define one typed capability. Let agents discover, pay for, and call it from the framework you already use.

Start with your coding agent

Install the versioned Lucid skill, then ask your agent to inspect the project before editing.

Run this from your project root, reload your agent, then ask it to use the Lucid Agents skill.

Seller path

Sell a paid API

Define a typed capability, advertise one clear price, and receive x402 payments.

Buyer path

Build a budgeted buyer

Call paid services from a server-side wallet with recipient and spending policy.

Application path

Keep your framework

Add Lucid to Hono, Express, Next.js, or TanStack Start without duplicating runtime logic.

More than a 402 response

Lucid composes schema validation, payment admission, policy, fulfillment, settlement, idempotency, tasks, discovery, and durable state around the payment rail.

  • Advertise one typed capability and price
  • Challenge and verify the buyer
  • Reserve policy capacity before fulfillment
  • Settle, record, and return the typed result
paid-service.tsCompiled in CI
import { createAgent } from '@lucid-agents/core';
import { createAgentApp } from '@lucid-agents/hono';
import { http } from '@lucid-agents/http';
import { payments, paymentsFromEnv } from '@lucid-agents/payments';
import { z } from 'zod';

const runtime = await createAgent({
  name: 'text-service',
  version: '0.1.0',
  description: 'Paid text analysis',
})
  .use(http())
  .use(payments({ config: paymentsFromEnv() }))
  .build();

const { app, addEntrypoint } = await createAgentApp(runtime);

addEntrypoint({
  key: 'analyze',
  description: 'Count the words and characters in text',
  price: '0.01',
  input: z.object({ text: z.string().min(1) }),
  output: z.object({ words: z.number(), characters: z.number() }),
  handler: async ({ input }) => ({
    output: {
      words: input.text.trim().split(/\s+/u).length,
      characters: input.text.length,
    },
  }),
});

export { app };

One runtime contract from prototype to production.

Framework-portable

One canonical HTTP route and authorization contract across Hono, Express, Next.js, and TanStack Start.

Protocol-composable

Use the verified x402 v2 exact path first; add only the versioned Next protocol subsets documented in each compatibility page.

Production-shaped

Move from in-memory defaults to explicit durable payment, entitlement, task, and scheduler ports.

Start with one paid call.

Observe the x402 challenge, complete a Base Sepolia payment, then follow the production checklist before moving real funds.

Open the paid API quickstart