AI Gateway logs now show session affinity
Vercel’s AI Gateway now groups AI requests into sessions in logs, showing how session affinity routes each turn and improving cache efficiency for repeated prompts.
Vercel has added a Sessions view to AI Gateway logs that organizes requests into sessions, allowing users to track how session affinity routes each interaction. Each session entry displays the coding agent or application responsible, such as Claude Code, Codex, or Cursor, along with associated costs, models, providers, and cumulative input caching metrics. The view aggregates data across every turn in the session, including cache hit rates, total duration, and a detailed path of each interaction. The path records model usage and timing for every turn while identifying the provider handling the session and any prior providers involved.
Session affinity ensures that each turn in a conversation is routed to the same provider that served the previous turn, leveraging cached prompts to reduce redundant processing. This approach improves efficiency by allowing providers to reuse cached portions of prompts across multiple turns within the same session. Users can filter sessions by various attributes, including the number of turns, client, model, provider, authentication status, or cost, providing granular control over log analysis.
Single-turn sessions are excluded from the default view and only appear when the minimum turns filter is cleared, ensuring focused analysis on multi-turn interactions. Session affinity is enabled by default for text and chat requests, automatically grouping related requests into coherent sessions without additional configuration. This feature simplifies tracking and debugging by maintaining continuity across provider interactions within a conversation.
To manually group requests into sessions, users can include a consistent sessionId in providerOptions.gateway or send the same x-session-id header with each request in a conversation. Requests lacking an explicit session identifier are grouped using a fingerprint of the conversation’s opening prompt, resulting in fingerprinted sessions that may span multiple providers.