Skip to main content
The LLM Gateway makes it easy to expose your commerce capabilities as tools for OpenAI’s GPT models. This allows you to build custom GPTs or integrate shopping into your own ChatGPT-powered applications.

Overview

OpenAI uses “Function Calling” to allow the model to interact with external APIs. The gateway automatically converts your Zod-based tool definitions into the JSON Schema format that OpenAI expects.

Usage with OpenAI SDK

1. Setup the OpenAI Adapter

2. Generate Tool Definitions

Pass the generated tools to the OpenAI chat completions API:

3. Handle Tool Calls

When the model decides to call a tool, use the gateway to execute it and return the result:

Creating a Custom GPT

If you want to create a “Store Assistant” GPT on the OpenAI Store:
  1. Deploy your LLM Gateway to a public URL (e.g., using Vercel).
  2. In the GPT Editor, go to Actions -> Create new action.
  3. Import the OpenAPI schema generated by the gateway at https://your-gateway.com/openapi.json.
  4. Configure your API key for authentication.

Best Practices

  • Model Selection: Use gpt-4-turbo or newer for the most reliable tool calling.
  • System Prompt: Give the model clear instructions on when and how to use the commerce tools.
  • Error Handling: OpenAI is sensitive to malformed tool responses. The gateway handles this by always returning structured JSON even on failure.