Reference
The LLMGateway constructor accepts a configuration object that defines your backends, adapters, and environment settings.
1import { LLMGateway } from '@commercegateway/commerce-gateway';2 3const gateway = new LLMGateway(config);backends (Required)An object containing implementations of the core commerce interfaces.
products: ProductBackend - Required.cart: CartBackend - Optional.orders: OrderBackend - Optional.links: LinkGenerator - Optional.sessionConfiguration for conversation state management.
redis: { url: string; token?: string } - Use for persistent sessions.ttl: number - Session expiration in seconds (default: 86400).keyPrefix: string - Prefix for Redis keys (default: bd-session:).authAccess control settings.
apiKeys: string[] - List of allowed API keys for the gateway.secret: string - Secret for signing JWTs or webhooks.llmProvidersList of LLM providers to optimize for. This influences the "personality" and formatting of tool responses.
anthropicopenaigrokgoogle (Gemini) - COMING SOONlogginglevel: 'debug' | 'info' | 'warn' | 'error'format: 'json' | 'pretty'external: Function for custom log aggregation.The gateway also respects several environment variables for easy deployment on platforms like Vercel or Docker.
| Variable | Description |
|----------|-------------|
| REDIS_URL | Redis connection string. |
| REDIS_TOKEN | Auth token for Redis (Upstash). |
| GATEWAY_API_KEY | Default API key for the gateway. |
| LOG_LEVEL | Logging verbosity. |
| PORT | The port to listen on (default: 3000). |
You can also register backends and tools after initialization:
1gateway.registerBackend('custom', myPrivateBackend);2gateway.enableTool('check_inventory');