How I Built an Agentic Memory Service with x402 Payments and Sentence-Transformers

AI agents forget everything between sessions. I built Memory01 — a persistent memory service designed for agents.

The Problem

Every time an agent starts a new session, it loses all context. You can stuff context into the prompt, but that's expensive and limited. You can use a vector database, but that requires setup, API keys, and infrastructure.

I wanted something simpler: an HTTP API where an agent can store a memory and search it later. No setup, no API keys, no accounts.

The Solution: x402

The x402 protocol uses HTTP 402 Payment Required. The flow is:

  1. Client requests a resource
  2. Server returns 402 with payment terms (amount, currency, network, payTo)
  3. Client pays in USDC on Base
  4. Client retries with payment proof
  5. Server returns the resource

No accounts. No API keys. No billing dashboard. Just HTTP and crypto.

Architecture

Agent → POST /api/memory/store → Flask → Redis → write_token Agent → POST /api/memory/search → Flask → Redis → embeddings → cosine similarity → results 

Storage

Redis-backed. Each memory is a key/value pair with optional metadata and session ID. Memories are scoped per write_token (one token per IP).

Search

Semantic search using paraphrase-multilingual-MiniLM-L12-v2 (384-dim, CPU-only). The model handles 50+ languages natively, including cross-lingual search (Italian query finds English memories).

Free Tier

  • Store: always free
  • Search: 30 free/day per agent, then $0.01 USDC
  • Soft limit: slowdown after 10 searches
  • Hard limit: 429 after 30 searches

Code Example

Store a memory

curl -X POST https://memory.node01.org/api/memory/store \ -H "Content-Type: application/json" \ -d '{"agent_id": "my-agent", "key": "pref", "value": "dark mode"}' 

Response:

{"ok": true, "stored": true, "write_token": "abc123...", "message": "Save this write_token!"} 

Search memories

curl -X POST https://memory.node01.org/api/memory/search \ -H "Content-Type: application/json" \ -d '{"agent_id": "my-agent", "write_token": "abc123...", "query": "user preferences"}' 

MCP Wrapper

npm install -g memory-agent-mcp 

What I Learned

  1. Free tiers are tricky. 30 free searches/day is too generous. Agents never hit the paywall. I'm reducing to 5/day for new agents.

  2. Cross-lingual search works surprisingly well. No translation needed. The multilingual model handles it natively.

  3. MCP wrappers matter more than HTTP. Agents discover via MCP, not HTTP endpoints. I published memory-agent-mcp on npm.

  4. x402 ecosystem is tiny. 18,373 endpoints, 1,308 services, $326K/month total volume. Top 10 = 95.4%. It's early.

  5. Distribution > Product. I spent 2 weeks building services nobody knows about. Post on Reddit/HN/Discord BEFORE writing code.

Numbers (honest)

  • Total revenue: $0.18 (all self-pay)
  • External buyers: 2 ($0.012 total)
  • Traffic: 32K+ requests, 3,938 unique IPs
  • Compliance grade: A (14/14 checks)
  • Uptime: 100%

Links

Happy to answer questions about x402, semantic search, or the MCP wrapper approach.