GrayMatter Memory + Credits
This is the production operator view for memory quality and economic control.
Routes
/graymatter-memory(authenticated)/credits/:accountId?(authenticated)/buy-credits
GrayMatter Memory Dashboard
The dashboard combines polling + websocket updates to track:
- context pressure (
usedPct,wastePct) - memory hit quality (
hitRate,hotEntries) - cost signals (
burnRate, retrieval/write/assembly costs) - actionable recommendations (
compact,reindex,prune,expand)
Primary API surface:
GET /v1/memory/statsGET /v1/memory/runs?limit=NPOST /v1/memory/compactPOST /v1/memory/reindexPOST /v1/memory/prunePOST /v1/memory/expand
Live overlay events include memory/context/cost channels and alert pushes.
Credits Ledger Model
Credits are ledger-based and prepaid.
Balance model:
Balance = Sum(PaymentTransaction.credits) - Sum(UsageTransaction.credits)
Core invariants:
- no negative credit values
- idempotency key support to prevent duplicate charges/credits
- derived balance from ledger entries (not mutable counter state)
Key endpoints used by the UI:
GET /v1/credits/{accountId}/balancePOST /v1/credits/{accountId}/usagePOST /v1/credits/{accountId}/paymentPOST /api/llm/pass/{accountId}(pass-through usage lane)
Operating Playbook
- Watch memory hit rate and waste in
/graymatter-memory. - Execute one recommendation action at a time.
- Validate credits balance before high-volume workflow runs.
- Use idempotency keys for payment/usage writes when integrating external clients.
Result: better memory quality, cleaner context windows, and fewer billing surprises.