Session
Sessions group related gateway requests and agent runs into one user journey, workflow execution, or multi-step task.
Use sessions when a single business interaction includes multiple model calls, tool calls, retries, or agent runs. A support conversation, n8n workflow execution, research job, or paid endpoint call can all be represented as sessions.
Session vs Run vs Request
Use one session ID across related runs. Use a new run ID for each task. Use a unique request ID for each gateway request.
Recommended Headers
Example:
Session Analytics
Session analytics helps answer:
- Which sessions are active, completed, or intercepted?
- Which agents and workflows created the most session cost?
- Which sessions contain policy events?
- Which sessions had high latency, repeated retries, or unusual token usage?
- Which session steps contributed to total cost?
The lower-level Analytics API includes session endpoints for session lists, vitals, and session detail. Use the API Reference for exact parameters and response shapes.
Implementation Pattern
- Generate or load a stable session ID when the conversation, workflow, or job starts.
- Generate a new Run ID for each agent task inside the session.
- Send
alephant-session-id,Alephant-Agent-Id, andAlephant-Run-Idwith every gateway request. - Send
x-request-idfor each individual request when your application can generate one. - Query logs, analytics, or session detail views to inspect cost, policy events, and execution steps.