What to store
A compact support bot
Python SDK
Limits
Message limits
Summarize before the history approaches the chosen model’s context window. A practical pattern is one structured summary plus the most recent 10–20 turns. This keeps latency and token cost predictable while your database remains the source of truth.Legacy sessions
The legacyPOST /api/v1/chat path still supports server-side session memory for integrations built against it. It is a compatibility surface — new applications should keep state client-side as shown above. These routes are deliberately not wrapped by the SDKs — the clients guide you toward owning your own history. Call them as raw REST with your Authorization: Bearer header.
Sessions expire 7 days after their last write. A session holds at most 100 messages — past that the store keeps only the most recent 50 — and once it passes 60 messages the older turns are compacted in the background into a summary plus the most recent 20. Session ids are scoped to your account; an unknown or foreign id returns
404 not_found. session_id is not accepted on /responses or /chat/completions (400 unsupported_parameter).