Overview
By default, each/chat/completions request is stateless. Send store: true and OkraPDF creates a server-side session that accumulates message history. Follow-up requests only need the new user message — prior context is loaded automatically.
OpenAI-compatible.
store and metadata are both official OpenAI fields. No invented parameters.How it works
Step 1: Start a session
Send"store": true to create a session. The response includes metadata.session_id.
Step 2: Follow up
Pass thesession_id in metadata. Only send the new user message — the server prepends prior history.
Step 3: Manage sessions
With the OpenAI SDK
Behavior matrix
metadata.session_id | store | messages | Behavior |
|---|---|---|---|
| absent | absent/false | required | Stateless (default, unchanged) |
| absent | true | required | Auto-create session, return session_id |
| present | — | 1 message | Resume: prepend history, append new message |
| present | — | full array | Replace: use provided messages, update session |
Security
- Sessions are scoped to the API key’s
user_id— you cannot load another user’s session - Session data is never exposed to the LLM’s
query_sqltool - Sessions expire after 24 hours of inactivity (lazy GC)
DELETE /sessions/:idimmediately removes all stored messages