Tools & Resources

May 23, 2026

13 min read

Building a Predictive Inventory Engine with OpenAI

A technical walkthrough of the demand forecasting model we built for a DTC brand — reducing stockouts from 23% to 2% and saving $1.2M in lost sales annually.

JK

Joe K

Founder, JMK Ventures

May 23, 2026

13 min read

Share

The $1.2M Problem

Stockouts are the silent killer of DTC ecommerce. Every time a customer lands on a product page and sees "Out of Stock," you don't just lose that sale — you lose future sales, because that customer goes to a competitor and may never come back. For our client, a fast-growing DTC beauty brand doing $18M annually, stockouts were happening on 23% of SKUs at any given time, costing an estimated $1.2M in lost sales per year.

The root cause was simple: they were ordering inventory based on gut feel and trailing 30-day averages. In a business with seasonal trends, viral product moments, and 6-8 week lead times from manufacturers, backward-looking averages are essentially useless. By the time a trailing average showed a trend, it was already too late to act on it.

We proposed building a predictive inventory engine that could forecast demand 8-12 weeks out and generate automated reorder recommendations. Here's how we built it.

Data Foundation

Before writing a single line of model code, we spent two weeks building the data foundation. This is the part most teams skip — and it's the part that determines whether the model actually works.

We consolidated data from five sources: Shopify (daily sales by SKU for 24 months), Google Analytics (product page views and conversion rates), Meta Ads and Google Ads (campaign spend and performance by product), the manufacturer's portal (lead times, MOQs, and production schedules), and a manual spreadsheet of planned promotions and product launches.

The key insight was that sales data alone isn't enough for demand forecasting. You need to understand the drivers of demand — marketing spend, seasonal patterns, promotional calendars, and external events — to predict where demand is going, not just where it's been.

Model Architecture

We used a two-stage approach. The first stage is a time-series decomposition model (Prophet) that captures baseline demand patterns: weekly seasonality, monthly seasonality, annual seasonality, and long-term trend. This gives us a solid baseline forecast that accounts for predictable patterns.

The second stage is an OpenAI-powered adjustment layer that incorporates unstructured signals. This is where it gets interesting. We feed the model three types of inputs: planned marketing campaigns and their expected reach (from the marketing team's briefs), social media trend data (mentions, hashtag velocity, and sentiment from a Brandwatch integration), and competitive intelligence (competitor stockouts, pricing changes, and new product launches scraped from their sites weekly).

The OpenAI layer processes these unstructured inputs and outputs demand adjustment factors — essentially saying "the baseline forecast for SKU X is 500 units, but based on the planned TikTok campaign and the competitor stockout on a similar product, adjust upward by 35%."

The Reorder Engine

Predictions are only useful if they drive action. We built an automated reorder engine that runs daily and generates recommendations based on four inputs: the demand forecast (8-12 week window), current inventory levels (synced from ShipBob in real-time), manufacturer lead times (updated monthly), and safety stock targets (calculated dynamically based on demand variability per SKU).

The engine outputs a daily reorder report that tells the ops team exactly what to order, how much, and when — with confidence intervals so they can see which recommendations are high-certainty and which are more speculative. The team reviews and approves orders rather than building them from scratch, which cut the weekly purchasing process from 8 hours to 45 minutes.

Results

We ran the system in shadow mode for 4 weeks (generating recommendations without acting on them) to validate accuracy, then went live. The results after 60 days:

Stockout rate: 23% → 2%. The model caught demand spikes 3-6 weeks before they happened, giving enough lead time to adjust orders. The remaining 2% stockouts were all on new products with less than 8 weeks of sales history — exactly the limitation we expected.

Overstock reduction: 31%. Better forecasting doesn't just prevent stockouts — it prevents overstocking too. The brand reduced its average warehouse inventory by 31% while simultaneously reducing stockouts, freeing up significant working capital.

Annual impact: $1.2M in recovered revenue from eliminated stockouts, plus approximately $400K in reduced carrying costs from lower average inventory. Total ROI on the project was over 15x in the first year.

Lessons Learned

Three lessons from this build that apply to any predictive model project. First, data quality matters more than model sophistication. We spent 60% of the project timeline on data collection and cleaning, and 40% on actual modeling. That ratio felt wrong at the time but was absolutely right in hindsight.

Second, start with a simple model and add complexity only where it improves accuracy. Our initial Prophet-only model achieved 70% of the accuracy improvement. The OpenAI adjustment layer added the remaining 30%. If we'd started with the complex architecture, we'd have spent months debugging before seeing any value.

Third, the model is only as good as the actions it enables. The reorder engine — not the prediction model — is what actually moved the numbers. A perfect forecast sitting in a spreadsheet is worthless. Build the action layer alongside the prediction layer from day one.

AI StrategyAutomationGrowth

JK

Joe K

Founder, JMK Ventures

Joe Khoury leads AI strategy and automation engagements at JMK Ventures, building revenue infrastructure for growth-stage businesses across 60+ client transformations.

Want to Implement This?

Book a free 30-minute AI audit and we’ll show you how to apply these strategies to your business.

Get Free AI Audit →

This is some text inside of a div block.

This is some text inside of a div block.

The AI Growth Brief

Join 2,000+ operators getting actionable AI strategies, tool reviews, and automation playbooks every Thursday.

Subscribe Free →

This is some text inside of a div block.

Ready to capture AI traffic?

JMK Ventures builds the infrastructure that gets your brand cited by AI platforms at scale.

Book a Call →

Want to Implement This?

Book a free 30-minute AI audit and we'll show you how to apply these strategies to your business.

Get Free AI Audit →