> ## Documentation Index
> Fetch the complete documentation index at: https://betterdatainc.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Configuration

> Full reference for the LLMGateway configuration object

The `LLMGateway` constructor accepts a configuration object that defines your backends, adapters, and environment settings.

```typescript theme={null}
import { LLMGateway } from '@commercegateway/commerce-gateway';

const gateway = new LLMGateway(config);
```

## 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.

| 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`). |

## Advanced: Programmatic Registration

You can also register backends and tools after initialization:

```typescript theme={null}
gateway.registerBackend('custom', myPrivateBackend);
gateway.enableTool('check_inventory');
```
