WooCommerce
WooCommerce integration with the OpenAI and Claude APIs: token costs, rate limits and API key security

A WooCommerce integration with OpenAI or Claude connects your store to a language model API through a plugin that runs on the server. Whether the integration is any good comes down to three things: control over token costs, handling of rate limits and where the API key is stored. I’m writing this for a store owner, operations director or IT manager who has a developer’s quote on their desk and is wondering whether to sign it. I’ll show you what a solid implementation looks like, what to ask before signing and where to start.
Table of Contents
How does a WooCommerce integration with OpenAI and Claude work?
The mechanics are simple. The store sends a request to the provider’s API, for example product data, and the model sends back text that the plugin saves in the database or shows in the admin panel. In WooCommerce this usually means product descriptions, answers to customer questions, review summaries, and tagging and categorizing products. An off-the-shelf plugin covers the typical scenarios. And that’s it. An integration built for a specific store goes further: it takes into account the store’s processes, custom fields, data sources and which employees have access to what.
How are tokens counted in AI APIs and what does it cost?
You pay for tokens, which are pieces of text. You pay separately for what you send to the model (input) and for what the model generates (output). A token is part of a word, a whole short word or a punctuation mark. Also, Polish text usually splits into more tokens than English, because inflection produces lots of less common word forms. So the same product description in Polish generally costs more than its English version. What keeps the bill under control:
- a response length limit set in every request,
- matching the model to the task: a cheaper one for tagging, a stronger one for sales copy,
- batch processing of large product sets instead of single calls,
- saving generated text in the database instead of generating it on every page view,
- a monthly budget and usage alerts set with the provider and in the plugin.
Not every store wants to open its own account with a provider and keep track of invoices. There is another way: in our plugins that support credits, you pay for AI usage with AI credits for plugins assigned to your account in our store, without a separate API account.
Claude and OpenAI API rate limits: what happens when a store sends too many requests?
Providers limit the number of requests and tokens within a given time. Go over the limit and the API returns an error instead of a response. In a store it looks like this: a bulk import stops halfway through generating descriptions, or the chat goes quiet right at peak traffic. Not great. A solid integration puts tasks in a queue (WP-Cron or Action Scheduler), retries them with increasing delays and works in the background, not during a customer’s request. Every error goes into a readable log. One more thing: limits grow along with your account history at the provider, so plan a gradual start in your rollout schedule instead of launching everything on day one.
AI API key in a plugin: where to store it so it doesn’t leak?
On the server. Only there. The customer’s browser must never see it. A key placed in JavaScript or any other front-end code can be read by every visitor, who can then use the model at the store’s expense. A secure implementation follows a few rules:
- API requests go through your own PHP endpoint,
- the key is stored in wp-config.php or an environment variable, not in a regular database option,
- a separate key for each store and environment (production, test),
- only the administrator has access to the settings,
- a spending limit is set with the provider and the key is rotated regularly.
The endpoint itself also needs protection: a nonce, permission checks and rate limiting. Otherwise someone will turn it into a free proxy to the model (and this is not a theoretical threat). Don’t send more of your customers’ personal data to the API than the task requires, which also makes GDPR compliance easier.
What questions should you ask an AI developer?
The point is to check whether the developer thinks about costs, limits and security, or only about making everything look good in a demo. In my opinion, this list is enough:
- Where will the key be stored and who will have access to it?
- How will you estimate token usage and how will you limit it?
- What happens when the store exceeds the rate limit?
- Can we switch providers, from OpenAI to Claude and back, without rewriting the plugin?
- What store and customer data will be sent to the API?
- How do error logging and cost monitoring work?
- Who maintains the integration after WooCommerce updates and API changes?
A red flag? A proposal to call the API directly from the browser. A project like that sooner or later ends with a leaked key. It’s not worth the risk.
Where to start so you don’t burn through your budget?
With one process you can measure. For example, product descriptions in a single category. You expand the scope only after you’ve assessed the results. The order goes like this: you pick a process, test it on a small sample and set a spending limit. A person reads and evaluates the generated content, and you decide on scaling based on quality and actual token usage, not gut feeling. For a standard catalog, an off-the-shelf plugin is more than enough. But with unusual processes, custom fields, an ERP connection or a multilingual store, a custom WooCommerce AI plugin works better.
A well-planned WooCommerce integration with OpenAI or Claude keeps the key on the server from day one, watches token usage and handles rate limits without interrupting the store. Need something tailored to your processes? Describe them to us, and in our quote we’ll suggest what a custom-built integration could look like.
Frequently asked questions
Can I use OpenAI and Claude at the same time in one store?
Yes, as long as the plugin has an intermediate layer that separates the store logic from a specific provider, and a separate key for each of them. Then you can assign different models to different tasks, e.g. one for product descriptions and another for answering customer questions.
Is an API key saved in the plugin settings secure?
It depends. Mainly on whether the key ends up in the page code and who has access to the admin panel. If it’s visible in the browser or many accounts can access it, the risk is high. It’s safer to keep it in the server configuration and also set a spending limit with the provider.
How do I estimate the monthly API cost before implementation?
Run a test on a representative sample, e.g. a few dozen products, and measure input and output token usage per task. Multiply the result by the planned scale and the price list of the chosen model. It’s simple, and the forecast is much more reliable than a rough guess.