Most AI tools have no memory. Every session starts from zero—your agent forgets preferences, context, decisions, and everything it learned five minutes ago. Smara gives any AI tool persistent, searchable, decay-scored memory through a simple REST API.
This guide gets you from zero to working memory in under five minutes. Pick your language, copy the examples, and ship.
All endpoints live under https://api.smara.io/v1. Authenticate with a Bearer token.
| Method | Endpoint | Description |
|---|---|---|
| POST /v1/memories | Store a new memory | |
| GET /v1/memories | List all memories | |
| POST /v1/memories/search | Semantic search | |
| DELETE /v1/memories/:id | Delete a memory |
Sign up at smara.io and grab your key from the dashboard. Free tier gives you 100 memories, no credit card required.
# Add to your .env or shell profile
export SMARA_API_KEY="smr_xxxxxxxxxxxx"
If you want automatic memory in Claude Code, Cursor, or Windsurf:
npx @smara/mcp-server --init
No SDK package needed—use plain fetch. Works in Node.js 18+, Deno, Bun, and browsers.
const API = "https://api.smara.io/v1";
const KEY = process.env.SMARA_API_KEY;
const res = await fetch(`${API}/memories`, {
method: "POST",
headers: {
"Authorization": `Bearer ${KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
user_id: "user-123",
content: "Prefers dark mode and Vim keybindings in all editors",
tags: ["preferences", "editor"],
importance: 0.8,
namespace: "my-app",
}),
});
const memory = await res.json();
console.log(memory);
// { id: "mem_abc123", content: "Prefers dark mode...", score: 0.8, ... }
const results = await fetch(`${API}/memories/search`, {
method: "POST",
headers: {
"Authorization": `Bearer ${KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
user_id: "user-123",
q: "editor preferences",
top_n: 5,
namespace: "my-app",
}),
}).then(r => r.json());
console.log(results.memories);
// [{ id: "mem_abc123", content: "Prefers dark mode...", score: 0.92, decay: 0.98 }]
const all = await fetch(
`${API}/memories?user_id=user-123&namespace=my-app&limit=20`,
{ headers: { "Authorization": `Bearer ${KEY}` } }
).then(r => r.json());
console.log(`${all.total} memories found`);
await fetch(`${API}/memories/mem_abc123`, {
method: "DELETE",
headers: { "Authorization": `Bearer ${KEY}` },
});
// 204 No Content
Uses the requests library. Install with pip install requests if you don't have it.
import os, requests
API = "https://api.smara.io/v1"
KEY = os.environ["SMARA_API_KEY"]
HEADERS = {"Authorization": f"Bearer {KEY}", "Content-Type": "application/json"}
res = requests.post(f"{API}/memories", headers=HEADERS, json={
"user_id": "user-123",
"content": "Prefers dark mode and Vim keybindings in all editors",
"tags": ["preferences", "editor"],
"importance": 0.8,
"namespace": "my-app",
})
memory = res.json()
print(memory)
# {"id": "mem_abc123", "content": "Prefers dark mode...", "score": 0.8, ...}
results = requests.post(f"{API}/memories/search", headers=HEADERS, json={
"user_id": "user-123",
"q": "editor preferences",
"top_n": 5,
"namespace": "my-app",
}).json()
for m in results["memories"]:
print(f"{m['score']:.2f} {m['content']}")
# 0.92 Prefers dark mode and Vim keybindings in all editors
all_memories = requests.get(
f"{API}/memories",
headers=HEADERS,
params={"user_id": "user-123", "namespace": "my-app", "limit": 20},
).json()
print(f"{all_memories['total']} memories found")
requests.delete(f"{API}/memories/mem_abc123", headers=HEADERS)
# 204 No Content
For quick testing or shell scripts. All examples assume SMARA_API_KEY is set.
curl -X POST https://api.smara.io/v1/memories \
-H "Authorization: Bearer $SMARA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"user_id": "user-123",
"content": "Prefers dark mode and Vim keybindings",
"tags": ["preferences", "editor"],
"importance": 0.8,
"namespace": "my-app"
}'
curl -X POST https://api.smara.io/v1/memories/search \
-H "Authorization: Bearer $SMARA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"user_id": "user-123",
"q": "editor preferences",
"top_n": 5,
"namespace": "my-app"
}'
curl "https://api.smara.io/v1/memories?user_id=user-123&namespace=my-app&limit=20" \
-H "Authorization: Bearer $SMARA_API_KEY"
curl -X DELETE https://api.smara.io/v1/memories/mem_abc123 \
-H "Authorization: Bearer $SMARA_API_KEY"
If you use Claude Code, Cursor, or Windsurf, you don't need to write any API calls. The Smara MCP server handles everything automatically.
npx @smara/mcp-server --init
This adds the Smara MCP server to your IDE settings. Or configure manually:
// Claude Code: ~/.claude/settings.json
// Cursor: .cursor/mcp.json
// Windsurf: ~/.windsurf/mcp.json
{
"mcpServers": {
"smara": {
"command": "npx",
"args": ["-y", "smara-mcp"],
"env": {
"SMARA_API_KEY": "smr_xxxxxxxxxxxx",
"SMARA_USER_ID": "your-name",
"SMARA_NAMESPACE": "my-project"
}
}
}
}
Once connected, your AI assistant will automatically:
Share memories across your team so every member's AI assistant has shared project context.
# Team memories use a shared namespace with a team_ prefix
curl -X POST https://api.smara.io/v1/memories \
-H "Authorization: Bearer $SMARA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"user_id": "team",
"content": "Our API uses camelCase for JSON fields and kebab-case for URLs",
"tags": ["conventions", "api"],
"importance": 0.9,
"namespace": "team_acme-corp"
}'
# Any team member can query shared memories
curl -X POST https://api.smara.io/v1/memories/search \
-H "Authorization: Bearer $SMARA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"user_id": "team",
"q": "API naming conventions",
"namespace": "team_acme-corp"
}'
SMARA_NAMESPACE to your team namespace, and use a separate personal namespace for individual preferences.
team_ prefix for shared team namespaces["auth", "security", "oauth"]| Score | Use For | Example |
|---|---|---|
| 0.9–1.0 | Critical rules | "Never expose API keys in client code" |
| 0.7–0.8 | Preferences & patterns | "Uses TypeScript strict mode" |
| 0.4–0.6 | Context & notes | "Last sprint focused on auth refactor" |
| 0.1–0.3 | Ephemeral facts | "Currently debugging issue #234" |
Smara uses Ebbinghaus decay curves to rank memories. Frequently accessed memories stay strong; unused ones fade. This means:
Store one fact per memory, not paragraphs. This improves search precision:
// Bad: one big memory
"Uses React with TypeScript, deploys to Vercel, prefers Tailwind, tests with Vitest"
// Good: separate memories
"Frontend framework: React with TypeScript"
"Deployment platform: Vercel"
"CSS framework: Tailwind CSS"
"Test runner: Vitest"
Free tier, no credit card. Start building AI tools with memory today.
Get Your API Key →