API Quickstart
Add user-scoped memory to any AI app through the MemoryRouter API.
Add user-scoped memory to any AI app. Change one URL, pass the user's Memory Key, and MemoryRouter retrieves and stores memory for that user's private vault.
This page covers proxy mode, where MemoryRouter sits in the model path. If your app calls the model provider directly and you want MemoryRouter for retrieval plus storage only, use Local inference mode with /memory/prepare and /memory/ingest.
# Before: Stateless AI with amnesia
client = OpenAI(api_key="sk-xxx")
# After: user-scoped AI memory
client = OpenAI(api_key="mk_xxx", base_url="https://api.memoryrouter.ai/v1")API Quickstart (5 minutes)
Step 1: Get Your Memory Key
- Go to app.memoryrouter.ai
- Sign in with Google
- Add your OpenAI/Anthropic API key(s) in Settings
- Copy your Memory Key (
mk_xxxxxxxxxxxxxxxx)
Step 2: Swap One Line
Python (OpenAI SDK):
from openai import OpenAI
client = OpenAI(
api_key="mk_xxxxxxxxxxxxxxxx", # Your Memory Key
base_url="https://api.memoryrouter.ai/v1"
)
response = client.chat.completions.create(
model="openai/gpt-5.5",
messages=[{"role": "user", "content": "My name is Alice"}]
)
print(response.choices[0].message.content)JavaScript:
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: 'mk_xxxxxxxxxxxxxxxx',
baseURL: 'https://api.memoryrouter.ai/v1'
});
const response = await client.chat.completions.create({
model: 'openai/gpt-5.5',
messages: [{ role: 'user', content: 'My name is Alice' }]
});curl:
curl -X POST https://api.memoryrouter.ai/v1/chat/completions \
-H "Authorization: Bearer mk_xxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-5.5",
"messages": [{"role": "user", "content": "My name is Alice"}]
}'Step 3: Watch the Memory Work
# First request - introduce yourself
client.chat.completions.create(
model="openai/gpt-5.5",
messages=[{"role": "user", "content": "My name is Alice and I love hiking"}]
)
# Later (even days later) - the AI remembers
response = client.chat.completions.create(
model="openai/gpt-5.5",
messages=[{"role": "user", "content": "What are my hobbies?"}]
)
# Response: "Based on our previous conversation, you mentioned you love hiking!"How It Works
MemoryRouter sits between your app and your AI provider:
- Queries your semantic-temporal memory store
- Injects relevant context into your prompt
- Forwards to your chosen AI provider
- Stores new memories automatically
- Returns the response, standard format, zero changes to your code
Memory Mode via Key Suffix
Control memory behavior from your API key, no extra headers needed:
| Key | Retrieve | Store | Use Case |
|---|---|---|---|
mk_xxx | ✅ | ✅ | Full memory (default) |
mk_xxx:read | ✅ | ❌ | Use past memories, don't store new ones |
mk_xxx:write | ❌ | ✅ | Store without retrieving (bulk ingestion) |
mk_xxx:off | ❌ | ❌ | Pure proxy pass-through, no memory |
The suffix is stripped before auth, same key, different behavior. Great for platforms where you can only set an API key (Open WebUI, LibreChat, etc.).
# Read-only: uses memory but doesn't store this conversation
client = OpenAI(api_key="mk_xxx:read", base_url="https://api.memoryrouter.ai/v1")For full per-request control, see Memory Control in the API Reference.
Supported Providers
Use any model from these providers, just prefix the model name:
| Provider | Example Models | Prefix |
|---|---|---|
| OpenAI | gpt-5.5, gpt-5.5-pro, gpt-chat-latest, o4-mini, o3-pro | openai/ |
| Anthropic | claude-opus-4.8, claude-opus-4.8-fast, claude-sonnet-4.6, claude-haiku-4.5 | anthropic/ |
| gemini-3.5-flash, gemini-3.1-pro-preview, gemini-3.1-flash-lite | google/ | |
| Meta | llama-4-maverick, llama-4-scout, llama-guard-4-12b | meta/ |
| Mistral | mistral-medium-3.5, mistral-large-2512, devstral-2512, ministral-14b-2512 | mistral/ |
| xAI | grok-4.3, grok-4.20, grok-4.20-multi-agent, grok-build-0.1 | x-ai/ |
| OpenRouter | any model on openrouter.ai (200+) | openrouter/ |
| DeepSeek | deepseek-v4-pro, deepseek-v4-flash, deepseek-v3.2 | deepseek/ |
| Perplexity | sonar-pro-search, sonar-reasoning-pro, sonar-deep-research | perplexity/ |
| Azure OpenAI | your deployed models | azure/ |
| Ollama | local models | ollama/ |
200+ models available through MemoryRouter and OpenRouter, including the latest GPT, Claude, Gemini, Llama, Mistral, Grok, DeepSeek, Perplexity, Qwen, Cohere, Together, and local Ollama models.
Links
- Dashboard: app.memoryrouter.ai
- API:
https://api.memoryrouter.ai/v1
MemoryRouter, Same memory, any model. 🧠