Skip to main content
The LLMGateway constructor accepts a configuration object that defines your backends, adapters, and environment settings.

Config Object

backends (Required)

An object containing implementations of the core commerce interfaces.
  • products: ProductBackend - Required.
  • cart: CartBackend - Optional.
  • orders: OrderBackend - Optional.
  • links: LinkGenerator - Optional.

session

Configuration 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:).

auth

Access control settings.
  • apiKeys: string[] - List of allowed API keys for the gateway.
  • secret: string - Secret for signing JWTs or webhooks.

llmProviders

List of LLM providers to optimize for. This influences the “personality” and formatting of tool responses.
  • anthropic
  • openai
  • grok
  • google (Gemini) - COMING SOON

logging

  • level: 'debug' | 'info' | 'warn' | 'error'
  • format: 'json' | 'pretty'
  • external: Function for custom log aggregation.

Environment Variables

The gateway also respects several environment variables for easy deployment on platforms like Vercel or Docker.

Advanced: Programmatic Registration

You can also register backends and tools after initialization: