Pay per call. No signup. Namespace-isolated. Audit-logged.
import httpx
# Store a legal memory
httpx.post("https://api.lawmem.ai/store",
headers={"Authorization": "Bearer YOUR_KEY"},
json={
"text": "Plaintiff alleges breach of NDA. "
"Disclosure occurred Feb 14 2024. "
"Seeking $500k damages under NY law.",
"matter_id": "case-2024-001",
"agent_id": "gpt-4-legal"
}
)
# Recall semantically similar memories
r = httpx.post("https://api.lawmem.ai/recall",
headers={"Authorization": "Bearer YOUR_KEY"},
json={"query": "NDA breach damages", "top_k": 5}
)
# → ranked results with cosine similarity scores
Namespace isolation ensures one firm's memories never touch another's. Every API key maps to a dedicated tenant_id — enforced at the query level, not the application level.
Every store and recall is logged with timestamp, wallet, agent ID, and query. PostgreSQL audit trail designed for e-discovery and compliance review. DPA available on request.
Powered by nomic-embed-text — 768-dimensional cosine similarity optimised for dense legal text: contracts, pleadings, depositions, and case notes.
First 1,000 calls are free — no API key purchase required. After the free tier, x402 payment on Base network handles billing automatically.
curl -X POST https://api.lawmem.ai/store \
-H "Authorization: Bearer YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"text": "Client retained firm for M&A due
diligence. Target: Acme Corp. NDA
signed 2024-01-15. Closing Q2 2024.",
"matter_id": "matter-acme-2024",
"agent_id": "due-diligence-agent",
"source_doc": "retainer_letter.pdf"
}'
# Returns: { "id": "uuid", "created_at": "..." }
curl -X POST https://api.lawmem.ai/recall \
-H "Authorization: Bearer YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "M&A due diligence NDA",
"matter_id": "matter-acme-2024",
"top_k": 5
}'
# Returns ranked results with cosine scores
# Each result includes text_preview, score,
# matter_id, agent_id, source_doc, created_at
# After 1,000 free calls → HTTP 402
# Agent pays $0.005 USDC on Base, retries
# with X-PAYMENT header
import httpx
BASE = "https://api.lawmem.ai"
KEY = "YOUR_KEY"
HDR = {"Authorization": f"Bearer {KEY}"}
def store(text, matter_id, agent_id="agent",
source_doc=None):
r = httpx.post(f"{BASE}/store",
headers=HDR,
json={
"text": text,
"matter_id": matter_id,
"agent_id": agent_id,
"source_doc": source_doc,
}
)
if r.status_code == 402:
# Free tier exhausted — pay via x402
handle_payment(r)
return
r.raise_for_status()
return r.json()["id"]
def recall(query, matter_id=None, top_k=5):
r = httpx.post(f"{BASE}/recall",
headers=HDR,
json={
"query": query,
"matter_id": matter_id,
"top_k": top_k,
}
)
if r.status_code == 402:
# x402: pay $0.005 USDC on Base
# Retry with X-PAYMENT header after
# submitting tx to eip155:8453
handle_payment(r)
return []
r.raise_for_status()
return r.json()["results"]
# results[0] → {
# "id": "...", "score": 0.87,
# "text_preview": "...",
# "matter_id": "...", "created_at": "..."
# }
const BASE = "https://api.lawmem.ai";
const KEY = "YOUR_KEY";
async function store(text, matterId, agentId) {
const res = await fetch(`${BASE}/store`, {
method: "POST",
headers: {
"Authorization": `Bearer ${KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
text: text,
matter_id: matterId,
agent_id: agentId,
}),
});
if (res.status === 402) {
const body = await res.json();
// body.accepts[0].payTo → USDC receiver
// body.accepts[0].maxAmountRequired → units
// body.accepts[0].network → eip155:8453
await handleX402Payment(body);
return;
}
return (await res.json()).id;
}
async function recall(query, matterId, topK=5) {
const res = await fetch(`${BASE}/recall`, {
method: "POST",
headers: {
"Authorization": `Bearer ${KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
query: query,
matter_id: matterId,
top_k: topK,
}),
});
if (res.status === 402) {
// x402: free tier exhausted
// Submit USDC tx on Base mainnet
// Retry with X-PAYMENT:
await handleX402Payment(await res.json());
return [];
}
const { results } = await res.json();
return results; // sorted by cosine score
}
Subscription plans via Stripe. Pay-as-you-go via x402 on Base. No credit card for free tier.
TLS 1.3 via Let's Encrypt. Auto-renewed. HSTS enabled.
Every API key is bound to a tenant_id. No cross-tenant data leakage — enforced at query level.
Every store, recall, and delete recorded in PostgreSQL with wallet, timestamp, and query hash.
Data Processing Agreement available to Legal Pro members.
Receiver wallet: 0x5F503…1fEAD ↗
DELETE /memory/{id} performs a hard delete from both vector store and PostgreSQL for legal compliance.