Skip to content

Latest commit

 

History

History
34 lines (23 loc) · 744 Bytes

File metadata and controls

34 lines (23 loc) · 744 Bytes

Stream: SSE

Pay-per-token LLM streaming using the SSE handler API. The server uses tempo.Sse.from() to create an SSE response that charges per token via stream.charge(). The client uses session.sse() to consume tokens as an async iterable, automatically handling voucher top-ups and receipts.

Setup

npx gitpick wevm/mppx/examples/session/sse
pnpm i

Usage

Start the server:

pnpm dev

In a separate terminal, run the client:

pnpm client
pnpm client "What is the meaning of life?"

Test with mppx CLI

With the server running, use the mppx CLI to make a paid request:

pnpm mppx localhost:5173/api/chat
pnpm mppx localhost:5173/api/chat?prompt=What+is+the+meaning+of+life?