Getting Started
Run + Expected Output
Running the Hello World Example
- Create a Next.js project (or use an existing one):
npx create-next-app@latest my-m4trix-app
cd my-m4trix-app- Install m4trix:
pnpm add @m4trix/core-
Create
app/api/chat/route.tswith the Hello World code. -
Start the dev server:
pnpm dev- 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
- What's Happening (Mental Model) — Understand the flow