lucidAGENTS
Examples

Core composition example

Compose HTTP, payments, wallets, identity, invoke, and streaming.

The repository's full-agent.ts is the broad composition example. It demonstrates:

  • conditional payments and identity extensions;
  • one Hono adapter over the canonical HTTP route plan;
  • a typed invoke capability;
  • a streamed capability using emit;
  • explicit USD decimal prices.

Run it from a repository checkout:

bun run packages/examples/src/core/full-agent.ts

For a paid deployment, provide the current environment names:

PAYMENTS_FACILITATOR_URL=https://YOUR_FACILITATOR_URL \
PAYMENTS_RECEIVABLE_ADDRESS=0xYOUR_ADDRESS \
PAYMENTS_NETWORK=eip155:84532 \
bun run packages/examples/src/core/full-agent.ts

This is a Next composition example. For the smaller Stable transaction that is installed from npm and executed in a clean room, use Sell a paid API.

Composition pattern

Extensions own their domains and the built runtime exposes those slices directly:

const runtime = await createAgent({ name: 'service', version: '1.0.0' })
  .use(http())
  .use(wallets({ config: walletsFromEnv() }))
  .use(payments({ config: paymentsFromEnv() }))
  .use(identity({ config: identityFromEnv() }))
  .build();

Add capabilities to the canonical registry, then let the adapter bind the runtime's route plan. Do not install an adapter-local paywall or a second entrypoint registry.

Price and streaming rules

price: '0.001' means 0.001 units of the configured USD-denominated asset. It is not a base-unit integer. A stream can have its own price:

runtime.entrypoints.add({
  key: 'generate',
  price: { invoke: '0.01', stream: '0.002' },
  input: z.object({ prompt: z.string() }),
  async stream({ input }, emit) {
    await emit({ kind: 'delta', delta: input.prompt, mime: 'text/plain' });
    return { status: 'succeeded' };
  },
});

Continue with streaming and metering, durable storage, and the production checklist.

On this page