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

# Multi-LLM Strategy

> How to build one backend for every AI assistant

One of the core design goals of `@commercegateway/commerce-gateway` is **portability**. This guide explains how to build a single commerce engine that serves multiple LLMs simultaneously.

## The Strategy

Instead of building separate integrations for Claude, ChatGPT, and Grok, you define your **Backends** and **Tools** once. You then spin up multiple "Adapters" that speak to the gateway core.

```mermaid theme={null}
graph TD
    B[Commerce Backend] --> G[LLM Gateway Core]
    G --> A1[Claude MCP Adapter]
    G --> A2[OpenAI Adapter]
    G --> A3[Grok Adapter]
    A1 --> C[Claude Desktop]
    A2 --> D[Custom GPT]
    A3 --> E[X / Grok]
```

## Implementation

You can run multiple adapters within the same application:

```typescript theme={null}
import { MCPServer } from '@commercegateway/commerce-gateway/mcp';
import { OpenAIAdapter } from '@commercegateway/commerce-gateway/openai';

const backends = { products: myProductBackend };

// 1. Start MCP Server for internal use
const mcp = new MCPServer({ backends });
mcp.start();

// 2. Start HTTP server with OpenAI adapter for public use
const openai = new OpenAIAdapter({ backends });
serveHttp(async (req) => {
  return await openai.handleRequest(req);
});
```

## Benefits of Multi-LLM

### 1. Consistency

Regardless of which AI the user talks to, the product data, pricing, and availability will be identical.

### 2. Lower Maintenance

When you add a new checkout feature or a reward program, you only implement it once in your `OrderBackend`. All connected LLMs automatically get the new capability.

### 3. Future Proofing

As new LLMs (like Google's Gemini) release tool-calling features, Better Data will add new adapters, allowing your store to expand to new ecosystems with zero code changes to your backends.

## Best Practices

* **Shared Sessions**: Use Redis to share the `sessionId` and cart across providers. This allows a user to "Start in Claude, finish in ChatGPT".
* **Capability Discovery**: Use the `getCapabilities` API to detect if a specific LLM support a feature (like streaming or image generation) before attempting to use it.
