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

# Migrating to the Drop-in Proxy

> Point your existing OpenAI, Responses, or Anthropic Messages client at Anona and get memory for free, no rewrite.

If you already have a chat integration, you don't need to learn the `record` /
`retrieve` API to add memory. The drop-in proxy speaks the exact wire format you're
already using; you change a base URL and a couple of headers, and every turn gets
memory recall and storage automatically.

## The idea

`/v1/chat/completions`, `/v1/responses`, and `/v1/messages` are wrapped versions of
the OpenAI Chat, OpenAI Responses, and Anthropic Messages APIs. Anona:

1. Retrieves the most relevant memories for the space (and scope, if you set one).
2. Injects them into the prompt.
3. Calls the model.
4. Stores the user turn and the assistant reply back into the space.

All in one request. Your app makes the same call it always made.

> [!NOTE]
>
> You never provide an LLM key. Anona runs the model for you, and billing is metered
> in Anona credits, not by the underlying provider. `model` is optional — omit it to
> use the deployment default. If you name one, it has to be a model Anona actually
> serves (see [model selection](https://docs.memory.anonalabs.com/api-reference/model-selection.md)); a provider-specific
> id like an OpenAI or Anthropic model name isn't recognized and returns
> `400 unsupported_model`, so drop `model` from code you're migrating rather than
> carrying it over unchanged.

## Step 1: swap the base URL

```python OpenAI SDK theme={null}
from openai import OpenAI

client = OpenAI(
    api_key="anona_live_YOUR_KEY",          # was your OpenAI key
    base_url="https://api.anonalabs.com/v1", # was https://api.openai.com/v1
    default_headers={"X-Anona-Space-Id": "support-bot"},
)

response = client.chat.completions.create(
    model="gpt-oss",  # optional: omit to use the deployment default
    messages=[{"role": "user", "content": "What plan did I say I was on?"}],
)
```

```typescript TypeScript theme={null}
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "anona_live_YOUR_KEY",            // was your OpenAI key
  baseURL: "https://api.anonalabs.com/v1",  // was https://api.openai.com/v1
  defaultHeaders: { "X-Anona-Space-Id": "support-bot" },
});

const response = await client.chat.completions.create({
  model: "gpt-oss", // optional: omit to use the deployment default
  messages: [{ role: "user", content: "What plan did I say I was on?" }],
});
```

```bash cURL theme={null}
curl https://api.anonalabs.com/v1/chat/completions \
  -H "Authorization: Bearer anona_live_YOUR_KEY" \
  -H "X-Anona-Space-Id: support-bot" \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [{"role": "user", "content": "What plan did I say I was on?"}]
  }'
```

Nothing else in your call changes. `messages`, `stream`, `temperature`,
`max_tokens`, and any field the OpenAI SDK sends that Anona doesn't model
(`top_p`, `n`, `stop`, ...) are forwarded to the provider unchanged.

Using the Anthropic Messages shape or the OpenAI Responses shape instead? Same
pattern: point at `/v1/messages` or `/v1/responses` respectively. See
[Chat](https://docs.memory.anonalabs.com/api-reference/chat.md), [Responses](https://docs.memory.anonalabs.com/api-reference/responses.md), and
[Messages](https://docs.memory.anonalabs.com/api-reference/messages.md).

## Step 2: pick a space (and a scope, if you have multiple users)

`X-Anona-Space-Id` is the one thing worth setting explicitly. Skip it and the turn
lands in a space literally named `default`, created on the first call, which is harmless for
a quick test, but you don't want it in production.

If your app serves more than one end user, scope the turn too:

```python Python theme={null}
default_headers={
    "X-Anona-Space-Id": "support-bot",
    "X-Anona-User-Id": "alice",
}
```

```typescript TypeScript theme={null}
defaultHeaders: {
  "X-Anona-Space-Id": "support-bot",
  "X-Anona-User-Id": "alice",
}
```

```bash cURL theme={null}
-H "X-Anona-Space-Id: support-bot" \
-H "X-Anona-User-Id: alice"
```

See [Scoping memory by user, agent, or session](https://docs.memory.anonalabs.com/guides/scoping-multi-tenant.md) for the
full pattern.

## Step 3: tune what gets injected (optional)

Everything is sensible by default: 5 memories injected, auto-record on. Adjust with
headers so you never touch a call site:

| Header | Default | What it changes |
| - | - | - |
| `X-Anona-Memory-Limit` | `5` | How many memories to inject, 1-20. |
| `X-Anona-Memory-Tokens` | none | Approximate token cap for the injected block. |
| `X-Anona-Auto-Record` | `true` | Set `false` for read-only turns, e.g. evaluating against a space without polluting it. |
| `X-Anona-Memory` | `true` | Set `false` to skip recall/injection for one call entirely. |

Or set the same knobs once on the space itself, so every call inherits them without a
header:

```bash cURL theme={null}
curl -X PUT https://api.anonalabs.com/v1/spaces/support-bot/chat-settings \
  -H "Authorization: Bearer anona_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"memory_limit": 12, "auto_record": false}'
```

```python Python theme={null}
from anona import AnonaClient

AnonaClient(api_key="anona_live_YOUR_KEY").set_chat_settings(
    space_id="support-bot",
    memory_limit=12,
    auto_record=False,
)
```

```typescript TypeScript theme={null}
import { Anona } from "@anona-labs/memory";

await new Anona({ apiKey: "anona_live_YOUR_KEY" }).setChatSettings({
  spaceId: "support-bot",
  memoryLimit: 12,
  autoRecord: false,
});
```

See [Chat: memory tunables](https://docs.memory.anonalabs.com/api-reference/chat.md#memory-tunables) for full resolution
order (body → header → space default → platform default).

## Step 4: read what happened

Two extra fields on an otherwise-normal response tell you what memory did on that
turn:

```json theme={null}
{
  "choices": [ ... ],
  "memories_injected": 3,
  "space_id": "support-bot"
}
```

Streaming? The same two values arrive as `X-Anona-Memories-Injected` and
`X-Anona-Space-Id` response headers, from the first chunk.

## Verify it worked

Ask something that depends on a fact from an earlier turn, in a fresh request. If
memory is wired up, the model answers it without you re-sending the context:

```bash cURL theme={null}
# Turn 1
curl .../v1/chat/completions -d '{"messages":[{"role":"user","content":"I am on the Scale plan."}], ...}'

# Turn 2, new request, no history sent
curl .../v1/chat/completions -d '{"messages":[{"role":"user","content":"What plan am I on?"}], ...}'
# → answers "Scale" without you having resent turn 1
```

```python Python theme={null}
# Turn 1
client.chat.completions.create(
    messages=[{"role": "user", "content": "I am on the Scale plan."}],
)

# Turn 2, new request, no history sent
answer = client.chat.completions.create(
    messages=[{"role": "user", "content": "What plan am I on?"}],
)
print(answer.choices[0].message.content)  # → "Scale"
```

```typescript TypeScript theme={null}
// Turn 1
await client.chat.completions.create({
  messages: [{ role: "user", content: "I am on the Scale plan." }],
});

// Turn 2, new request, no history sent
const answer = await client.chat.completions.create({
  messages: [{ role: "user", content: "What plan am I on?" }],
});
console.log(answer.choices[0].message.content); // → "Scale"
```

## Next steps

> **[Chat API reference](https://docs.memory.anonalabs.com/api-reference/chat.md)**
>
> Every tunable, streaming details, space defaults.

> **[Scoping guide](https://docs.memory.anonalabs.com/guides/scoping-multi-tenant.md)**
>
> Serve many end users from one space.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.