The scenario
You already have working code against the OpenAI SDK. You want memory, and you do not want to restructure the app, learn a retrieval API, or hand-assemble a prompt. Change the base URL.Step 1 — Repoint the client
default_headers and no other hook.
Step 2 — Use it exactly as before
Step 3 — A new conversation still knows
Step 4 — Tune per call, or per space
Every option has a header, so a stock SDK can set it:X-Anona-User-Id, X-Anona-Memory-Limit, X-Anona-Memory (off),
X-Anona-Auto-Record, X-Anona-Block-Order. Set them once on the space instead
with chat settings.
X-Anona-User-Id per end user turns a single-tenant app multi-tenant with no
call-site change at all.
Evals
- Run two conversations as above. The second must answer from the first.
- Set
X-Anona-Memory: falseand confirm it does not — that comparison is your A/B. - Set
X-Anona-User-Idto two different values and confirm they do not share.
Guardrails
- Extraction is not instant. A question asked immediately after the fact was mentioned may miss it; the example sleeps for this reason.
modelis ours, not OpenAI’s. Use a tier alias likebalancedor an id fromGET /v1/models. An unknown name is a400, not a silent fallback.- Anthropic and Responses shapes work too, on
/v1/messagesand/v1/responses, with the same headers.x-api-keyis accepted anywhereAuthorizationis, because the Anthropic SDK never sets the latter.
The script
Complete and runnable:drop_in_proxy.py.