Skip to main content

Overview

Without sessions, you manage conversation history manually by sending all prior messages on every request. Sessions do this for you server-side, stored in Redis with a 7-day TTL.

Create a session

Response:
You can also omit session_id to get an auto-generated one:

Session ID format

session_id must match: ^[a-zA-Z0-9_-]{1,64}$ — alphanumeric, hyphens, and underscores, 1–64 characters. Good session IDs: user-123, conv_abc, proj-2026-march, thread_def456

Chat with a session

Add session_id to any /chat request. Previous messages are automatically injected before your new messages.
Second request (history is automatically included):
The model will respond: “You told me your name is Alice and you work in fintech.”

Chat response with session info

Retrieve a session

Export a session

Export as JSON or Markdown — useful for saving conversations, support tickets, or debugging.
The Markdown export returns a formatted document with headers and message blocks, ready to save as a .md file.

Delete a session

Limits and behavior

Code examples

Cache is automatically disabled when session_id is present — since history changes every request, cached responses would be incorrect.