Skip to contentMemoryRouterDocs
IntegrationsFrameworks and protocols

MemoryRouter / Documentation

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")

Prerequisites

Create a MemoryRouter account, select a vault, and add the required provider credentials in its dashboard settings. The examples use the Memory Key as the API credential; a bare MEMORY_KEY environment variable is not transmitted by generic SDKs. Keep credentials server-side.

Install the SDK you use:

# Python
pip install openai
# JavaScript / TypeScript
npm install openai

Choose a model actually available to the configured provider account. See supported models for routing boundaries.

API Quickstart (5 minutes)

Step 1: Get Your Memory Key

  1. Go to app.memoryrouter.ai
  2. Sign in with Google
  3. Add your OpenAI/Anthropic API key(s) in Settings
  4. 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: Cross-session proof

Send a first request containing: The synthetic demo release phrase is ORCHID-7419. Allow its response and background ingestion to complete. In a second request, pass only: What is the demo release phrase I told you before? with the same Memory Key. Do not carry over the first request's message history or include the answer in the question. Confirm ORCHID-7419 is recalled.

If it is missing, inspect the vault and retry after ingestion completes. This is a proof to run on your setup, not a guaranteed canned model response.

How It Works

MemoryRouter sits between your app and your AI provider:

  1. Queries your semantic-temporal memory store
  2. Injects relevant context into your prompt
  3. Forwards to your chosen AI provider
  4. Stores new memories automatically
  5. 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:

KeyRetrieveStoreUse 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

Model routing depends on provider credentials and endpoint compatibility. The examples below are identifiers, not a guarantee that every model supports every API feature. Verify availability in your provider account:

ProviderExample ModelsPrefix
OpenAIgpt-5.5, gpt-5.5-pro, gpt-chat-latest, o4-mini, o3-proopenai/
Anthropicclaude-opus-4.8, claude-opus-4.8-fast, claude-sonnet-4.6, claude-haiku-4.5anthropic/
Googlegemini-3.5-flash, gemini-3.1-pro-preview, gemini-3.1-flash-litegoogle/
Metallama-4-maverick, llama-4-scout, llama-guard-4-12bmeta/
Mistralmistral-medium-3.5, mistral-large-2512, devstral-2512, ministral-14b-2512mistral/
xAIgrok-4.3, grok-4.20, grok-4.20-multi-agent, grok-build-0.1x-ai/
OpenRouterany model on openrouter.ai (200+)openrouter/
DeepSeekdeepseek-v4-pro, deepseek-v4-flash, deepseek-v3.2deepseek/
Perplexitysonar-pro-search, sonar-reasoning-pro, sonar-deep-researchperplexity/
Azure OpenAIyour deployed modelsazure/
Ollamalocal modelsollama/

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.



MemoryRouter, Same memory, any model. 🧠

Limitations and troubleshooting

  • 401/403: verify the Memory Key and configured provider credentials. For BYOK passthrough, use the explicitly supported X-Memory-Key header plus provider authentication described in the API reference; exporting an unused variable does not authenticate a request.
  • 404/model error: check the base URL, API path, provider prefix, and actual model access. Do not append /v1 twice.
  • No new memories: check suffix/header storage controls. A :read key deliberately does not store; a :off key does neither retrieval nor storage.
  • Context or tool failure: a compatible HTTP shape does not guarantee parity for every streaming, tool-calling, media, or provider-specific feature. Test your actual request shape.
  • Privacy: inference requests pass through MemoryRouter in proxy mode. Use local inference if the provider call must remain in your stack.
  • Isolation: callers sharing a Memory Key share its vault. Use separate keys for users or projects that must not see each other's memories.

Next steps

View the integration · Create an account · All integrations

On this page