Getting Started
Sessions are critical for multi-turn commerce conversations. They allow the LLM to remember what's in the user's cart and maintain context across different platforms.
Every interaction with the LLM Gateway is associated with a sessionId. This ID is used to retrieve:
By default, the gateway uses an in-memory session manager, which is perfect for development but not suitable for production.
For production, use a Redis-based session manager to ensure high availability and shared state across multiple gateway instances.
1const gateway = new LLMGateway({2 session: {3 redis: {4 url: process.env.REDIS_URL,5 token: process.env.REDIS_TOKEN, "cmt">// Optional for serverless Redis like Upstash6 },7 ttl: 3600 * 24, "cmt">// 24 hour expiration8 }9});When using the HTTP Adapter, you typically pass the sessionId in the header or as part of the tool execution request.
1curl -X POST https://api.betterdata.co/v1/execute \2 -H "X-Session-Id: session_123" \3 ...The gateway will automatically look up the session and provide the associated cart to your backend handlers.
One of the unique features of the LLM Gateway is the ability to transfer sessions across different AI assistants.
