Skip to main content
Better Data LLM Gateway Hero

What is @betterdata/commerce-gateway?

@betterdata/commerce-gateway is a universal abstraction layer for building AI-powered shopping experiences across multiple LLM providers. Write your commerce logic once, and it works everywhere—Claude Desktop, ChatGPT, Grok, custom agents, and more.

Universal Tool Format

Define commerce tools once. Automatically convert to MCP, OpenAI Functions, or Grok formats.

Pluggable Backends

Connect to any e-commerce platform—Shopify, Square, WooCommerce, or custom systems.

Production Ready

Built-in auth, rate limiting, session management, and observability. Deploy with confidence.

Open Source

MIT licensed. Extend, customize, and contribute. No vendor lock-in.

The Problem

Building conversational commerce is fragmented:
1

Multiple LLM Formats

Claude uses MCP, OpenAI uses Function Calling, Grok has its own format. You need to implement your tools 3+ times.
2

Platform Lock-In

Hard-coded integrations to Shopify, Square, or WooCommerce mean rewriting everything to switch platforms.
3

Missing Production Features

Authentication, rate limiting, session management, and analytics aren’t included in base LLM SDKs.
4

Complex Setup

Getting from “hello world” to production-ready takes weeks of infrastructure work.

The Solution

@betterdata/commerce-gateway solves all of this:
import { createSimpleGateway } from '@betterdata/commerce-gateway';

const gateway = createSimpleGateway({
  backends: {
    products: myProductBackend,
    cart: myCartBackend,
    orders: myOrderBackend,
  },
});

// Works with Claude MCP
gateway.serveMCP();

// Works with ChatGPT
gateway.serveOpenAI();

// Works with Grok
gateway.serveGrok();

// Works with custom HTTP
gateway.listen(3000);
The gateway provides:
  1. Universal Tool Registry: Define tools once with Zod schemas
  2. Format Adapters: Automatic conversion to MCP, OpenAI, Grok formats
  3. Backend Interfaces: Clean contracts for commerce platforms
  4. Session Management: Redis-backed sessions with cross-platform transfer
  5. Production Infrastructure: Auth, rate limiting, observability
  • Claude Desktop MCP Servers: Native shopping in Claude
  • ChatGPT Plugins: Custom actions for ChatGPT
  • Grok/X Integrations: Tweet-optimized shopping on X/Twitter
  • Custom AI Agents: Your own conversational commerce bots
  • Multi-LLM Apps: One backend, multiple LLM frontends
Yes! Better Data uses this in production for our marketplace with:
  • 100+ vendors connected via Shopify and Square
  • 1M+ products searchable across multiple LLMs
  • 99.9% uptime with built-in error handling and retries
  • Sub-200ms latency for tool execution

Quick Example

Here’s a complete shopping assistant in < 50 lines:
import { 
  createSimpleGateway, 
  InMemoryCatalog 
} from '@betterdata/commerce-gateway';

// 1. Create product catalog
const catalog = new InMemoryCatalog();
await catalog.addProduct({
  id: '1',
  name: 'Wireless Headphones',
  price: 99.99,
  inStock: true,
});

// 2. Create gateway
const gateway = createSimpleGateway({
  backends: {
    products: catalog,
    cart: catalog,
    orders: catalog,
  },
});

// 3. Serve on Claude MCP
gateway.serveMCP();

// Now Claude Desktop can search products, add to cart, and checkout!
This example uses in-memory storage for simplicity. In production, connect to your real e-commerce platform.

Open Source vs Hosted


Key Features

🎯 Universal Tool Format

Define tools once, use everywhere:
const searchTool = createTool({
  name: 'search_products',
  description: 'Search for products',
  schema: z.object({
    query: z.string(),
    limit: z.number().default(10),
  }),
  handler: async ({ query, limit }) => {
    return await products.search(query, limit);
  },
});

// Automatically works with:
// ✓ Claude MCP
// ✓ OpenAI Function Calling
// ✓ Grok
// ✓ Custom HTTP APIs

🔌 Pluggable Backends

Connect to any commerce platform:
interface ProductBackend {
  searchProducts(query: string): Promise<Product[]>;
  getProductDetails(id: string): Promise<Product>;
  checkInventory(ids: string[]): Promise<InventoryStatus[]>;
}

// Implement once, use everywhere
const shopifyBackend = new ShopifyBackend({ ... });
const squareBackend = new SquareBackend({ ... });
const customBackend = new MyCustomBackend({ ... });

🔐 Production Infrastructure

Everything you need for production:
  • Authentication: API keys, OAuth, JWT
  • Rate Limiting: Per-key, per-IP, per-session
  • Session Management: Redis-backed with cross-platform transfer
  • Observability: Logs, metrics, traces
  • Error Handling: Retries, circuit breakers, graceful degradation
  • GDPR Compliance: Data export, deletion, consent management

📊 Built-in Analytics

Track everything:
// Automatic tracking
gateway.analytics.track({
  event: 'search',
  sessionId: 'session_123',
  metadata: {
    query: 'running shoes',
    results: 15,
    provider: 'anthropic',
  },
});

// Query metrics
const metrics = await gateway.analytics.getMetrics({
  startDate: '2024-01-01',
  endDate: '2024-01-31',
});

Architecture


Who Uses This?

Single Store Owners

Connect your Shopify or Square store to Claude Desktop in 10 minutes.

Marketplace Operators

Run multi-vendor marketplaces with competitive ranking and analytics.

AI Developers

Build custom conversational commerce agents with production infrastructure.

Next Steps