Run + Expected Output

Running the Hello World Example

  1. Create a Next.js project (or use an existing one):

npx create-next-app@latest my-m4trix-app
cd my-m4trix-app
  1. Install m4trix:

pnpm add @m4trix/core
  1. Create app/api/chat/route.ts with the Hello World code.

  2. Start the dev server:

pnpm dev
  1. Call the API:

curl -X POST http://localhost:3000/api/chat \
  -H "Content-Type: application/json" \
  -d '{"query": "Hello"}'

Expected Output

You'll receive an SSE stream:

event: agent-response
data: {"name":"agent-response","meta":{"runId":"..."},"payload":{"answer":"You asked: Hello","done":true}}

Or from a browser, use EventSource or fetch with ReadableStream to consume the stream.

Next

Last updated