> ## Documentation Index
> Fetch the complete documentation index at: https://docs.memorylake.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Add persistent memory to your LLM calls in three steps

Get Memory Router running in three steps. The only changes to your application are the base URL, a `boundary_id` query parameter, and — in BYOK mode — one header.

<Note>
  Memory Router is in **private preview**. If the Memory Router card is not yet visible under **Integrations** in your console, contact [support@memorylake.ai](mailto:support@memorylake.ai) to request access.
</Note>

## Step 1: Get a key and a Boundary

1. Sign in to the [console](https://app.memorylake.ai) and create a MemoryLake API key (starts with `sk-`).
2. Open **Integrations → Memory Router API** and create a **Boundary** — the memory scope that binds your conversations to a workspace, project, and actors. Copy its id.

<Info>
  Keep your MemoryLake key in an environment variable such as `MEMORYLAKE_API_KEY`. See [Authentication](/authentication) for details on managing keys. Requests **without** a `boundary_id` still work, but run as plain passthrough with memory disabled.
</Info>

## Step 2: Pick a mode and swap the base URL

Both modes use the same endpoints — what differs is which keys you send:

| Mode                          | Keys                                                                                              |
| ----------------------------- | ------------------------------------------------------------------------------------------------- |
| **MemoryLake-hosted**         | MemoryLake key only, in the native auth header                                                    |
| **BYOK** (bring your own key) | Your provider key in the native auth header + MemoryLake key in the `x-memorylake-api-key` header |

| Protocol                  | Endpoint                                                    |
| ------------------------- | ----------------------------------------------------------- |
| OpenAI · Chat Completions | `POST https://app.memorylake.ai/openai/v1/chat/completions` |
| OpenAI · Responses        | `POST https://app.memorylake.ai/openai/v1/responses`        |
| OpenAI · Embeddings       | `POST https://app.memorylake.ai/openai/v1/embeddings`       |
| Anthropic · Messages      | `POST https://app.memorylake.ai/anthropic/v1/messages`      |

See [Deployment Modes](/features/memory-router/deployment-modes) for a full comparison.

### MemoryLake-hosted — one key

No provider account required. GPT, Claude, and Qwen model families are built in; pick any model by its native name.

<CodeGroup>
  ```ts TypeScript theme={null}
  import OpenAI from "openai";

  // Hosted: no provider account. MemoryLake runs the models,
  // so a single MemoryLake key is all you need.
  const client = new OpenAI({
    baseURL: "https://app.memorylake.ai/openai/v1",
    apiKey: process.env.MEMORYLAKE_API_KEY,
  });

  const resp = await client.chat.completions.create({
    model: "gpt-4o-mini",
    messages: [{ role: "user", content: "Hello!" }],
  }, { query: { boundary_id: process.env.MEMORYLAKE_BOUNDARY_ID } });
  ```

  ```py Python theme={null}
  from openai import OpenAI
  import os

  # Hosted: no provider account. MemoryLake runs the models,
  # so a single MemoryLake key is all you need.
  client = OpenAI(
      base_url="https://app.memorylake.ai/openai/v1",
      api_key=os.environ["MEMORYLAKE_API_KEY"],
  )

  resp = client.chat.completions.create(
      model="gpt-4o-mini",
      messages=[{"role": "user", "content": "Hello!"}],
      extra_query={"boundary_id": os.environ["MEMORYLAKE_BOUNDARY_ID"]},
  )
  ```

  ```bash cURL theme={null}
  curl "https://app.memorylake.ai/openai/v1/chat/completions?boundary_id=$MEMORYLAKE_BOUNDARY_ID" \
    -H "Authorization: Bearer $MEMORYLAKE_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "gpt-4o-mini",
      "messages": [{"role": "user", "content": "Hello!"}]
    }'
  ```
</CodeGroup>

### BYOK — your provider key

Keep your provider account. Your provider key goes in the provider's **native** auth header (`Authorization: Bearer` for OpenAI, `x-api-key` for Anthropic); the MemoryLake key rides in the `x-memorylake-api-key` header.

<CodeGroup>
  ```ts TypeScript theme={null}
  import OpenAI from "openai";

  // BYOK: you send your own provider key. It is encrypted in transit,
  // forwarded to the provider, and never stored.
  const client = new OpenAI({
    baseURL: "https://app.memorylake.ai/openai/v1",
    apiKey: process.env.OPENAI_API_KEY,        // your provider key
    defaultHeaders: {
      "x-memorylake-api-key": process.env.MEMORYLAKE_API_KEY,
    },
  });

  const resp = await client.chat.completions.create({
    model: "gpt-4o-mini",
    messages: [{ role: "user", content: "Hello!" }],
  }, { query: { boundary_id: process.env.MEMORYLAKE_BOUNDARY_ID } });
  ```

  ```py Python theme={null}
  from openai import OpenAI
  import os

  # BYOK: you send your own provider key. It is encrypted in transit,
  # forwarded to the provider, and never stored.
  client = OpenAI(
      base_url="https://app.memorylake.ai/openai/v1",
      api_key=os.environ["OPENAI_API_KEY"],        # your provider key
      default_headers={
          "x-memorylake-api-key": os.environ["MEMORYLAKE_API_KEY"],
      },
  )

  resp = client.chat.completions.create(
      model="gpt-4o-mini",
      messages=[{"role": "user", "content": "Hello!"}],
      extra_query={"boundary_id": os.environ["MEMORYLAKE_BOUNDARY_ID"]},
  )
  ```

  ```bash cURL theme={null}
  curl "https://app.memorylake.ai/openai/v1/chat/completions?boundary_id=$MEMORYLAKE_BOUNDARY_ID" \
    -H "Authorization: Bearer $OPENAI_API_KEY" \
    -H "x-memorylake-api-key: $MEMORYLAKE_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "gpt-4o-mini",
      "messages": [{"role": "user", "content": "Hello!"}]
    }'
  ```
</CodeGroup>

### Anthropic SDK

With the Anthropic SDK, set the base URL to `https://app.memorylake.ai/anthropic` — the SDK appends `/v1/messages` itself.

<CodeGroup>
  ```ts TypeScript theme={null}
  import Anthropic from "@anthropic-ai/sdk";

  const client = new Anthropic({
    baseURL: "https://app.memorylake.ai/anthropic",
    apiKey: process.env.MEMORYLAKE_API_KEY,   // or your Anthropic key + x-memorylake-api-key header for BYOK
  });

  const resp = await client.messages.create({
    model: "claude-sonnet-5",
    max_tokens: 1024,
    messages: [{ role: "user", content: "Hello!" }],
  }, { query: { boundary_id: process.env.MEMORYLAKE_BOUNDARY_ID } });
  ```

  ```py Python theme={null}
  import anthropic
  import os

  client = anthropic.Anthropic(
      base_url="https://app.memorylake.ai/anthropic",
      api_key=os.environ["MEMORYLAKE_API_KEY"],
  )

  resp = client.messages.create(
      model="claude-sonnet-5",
      max_tokens=1024,
      messages=[{"role": "user", "content": "Hello!"}],
      extra_query={"boundary_id": os.environ["MEMORYLAKE_BOUNDARY_ID"]},
  )
  ```

  ```bash cURL theme={null}
  curl "https://app.memorylake.ai/anthropic/v1/messages?boundary_id=$MEMORYLAKE_BOUNDARY_ID" \
    -H "x-api-key: $MEMORYLAKE_API_KEY" \
    -H "anthropic-version: 2023-06-01" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "claude-sonnet-5",
      "max_tokens": 1024,
      "messages": [{"role": "user", "content": "Hello!"}]
    }'
  ```
</CodeGroup>

<Tip>
  The console's **Integrations → Memory Router API** page generates these snippets for you, pre-filled with your Boundary id, across cURL / Python / Node.js and both modes.
</Tip>

## Step 3: Call as normal

Send requests exactly as you do today. With a `boundary_id` attached, relevant memories are recalled into the prompt automatically, and new memories are extracted and stored asynchronously — the response is never delayed.

```ts TypeScript theme={null}
const completion = await client.chat.completions.create({
  model: "gpt-4o-mini",
  messages: [{ role: "user", content: "Remind me what we decided last time." }],
}, { query: { boundary_id: process.env.MEMORYLAKE_BOUNDARY_ID } });

console.log(completion.choices[0].message.content);
```

Check the `X-Trace-ID` response header and the console **Logs** page to confirm the call went through the Router — see [Observability](/features/memory-router/observability).

<Note>
  Newer OpenAI reasoning models (`gpt-5` family, `o1`/`o3`/`o4`) expect `max_completion_tokens` instead of `max_tokens` on Chat Completions. Keep your parameters in the provider's official format — the Router passes them through unchanged.
</Note>

## Next Steps

<CardGroup cols={2}>
  <Card title="Deployment Modes" icon="key" href="/features/memory-router/deployment-modes">
    Full comparison of BYOK and hosted, plus supported providers.
  </Card>

  <Card title="Observability" icon="activity" href="/features/memory-router/observability">
    Trace requests and understand the error contract.
  </Card>
</CardGroup>
