> ## Documentation Index
> Fetch the complete documentation index at: https://docs.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; `model` is a hint, and
  billing is metered in Anona credits, not by the underlying provider.
</Note>

## Step 1: swap the base URL

<CodeGroup>
  ```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-4o-mini",
      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 '{
      "model": "gpt-4o-mini",
      "messages": [{"role": "user", "content": "What plan did I say I was on?"}]
    }'
  ```
</CodeGroup>

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](/api-reference/chat), [Responses](/api-reference/responses), and
[Messages](/api-reference/messages).

## 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 theme={null}
default_headers={
    "X-Anona-Space-Id": "support-bot",
    "X-Anona-User-Id": "alice",
}
```

See [Scoping memory by user, agent, or session](/guides/scoping-multi-tenant) 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 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}'
```

See [Chat: memory tunables](/api-reference/chat#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 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
```

## Next steps

<CardGroup cols={2}>
  <Card title="Chat API reference" icon="rectangle-terminal" href="/api-reference/chat">
    Every tunable, streaming details, space defaults.
  </Card>

  <Card title="Scoping guide" icon="users" href="/guides/scoping-multi-tenant">
    Serve many end users from one space.
  </Card>
</CardGroup>
