Add Memory to an OpenAI SDK App: Choose the Integration Boundary
Choose where an OpenAI SDK app retrieves persistent context: before a request, through a tool, or through a documented integration.

An OpenAI SDK application can retrieve persistent context before a model request, expose retrieval as a tool, or use a documented integration that manages part of that flow. The right boundary depends on when the application needs context and how much control it requires over reads and writes.
This guide concerns the general SDK integration. The separate OpenAI Agents SDK memory guide covers agent sessions. Do not assume an API option or session primitive from one library exists in the other.
Retrieve before the request when context is required
If every support reply needs the customer's current unresolved issue, the application can perform an authorized lookup before generation. This makes retrieval failures visible before the model produces an answer.
Keep the retrieved evidence separate from system instructions and preserve source IDs. Choose a bounded context budget and decide what to do when the memory service is unavailable. An empty result and a timeout should not both become “the customer has no history.”
Use tools when the need is conditional
A model may only need historical context for some questions. A retrieval tool can defer the lookup until it is useful, provided the application controls the allowed scope and validates arguments. The model should not choose another tenant's identifier.
This adds an execution branch. Test the cases where the model never calls the tool, calls it repeatedly, or asks for irrelevant evidence. A correct tool implementation does not guarantee correct tool selection.
Make the write policy explicit
Saving every model response can turn guesses into future evidence. Decide which source messages or confirmed outcomes should be stored, and preserve their provenance. Avoid two independent write paths unless duplicate handling is understood.
Supermemory's OpenAI integration documentation describes the supported setup. Use the API and package versions that match your project. This architectural walkthrough does not claim a live model call or provider write was executed.
Run a boundary test before a broad migration
Use one fictional preference and two conversations for the same authorized user. Capture the preference, wait for documented readiness, retrieve it, and inspect the actual model input. Repeat for another user, a correction, and removal.
Record which component handles history, selected context, and final generation. That makes a failure attributable instead of treating the SDK as one opaque memory system. Keep the old read path available while comparing behavior.
After choosing the integration boundary, follow the incremental rollout guide for capture review, shadow retrieval, and rollback.
To begin, get a Supermemory API key and connect the documented integration at one request boundary. Expand only after the read, write, and failure behavior is visible in your application's traces.