Skip to content

Google Cloud Vertex AI

Call the Google Cloud Retail API on Every Request

Caching search and browse responses from Google Cloud's Retail API degrades AI model training and risks serving personalized results to the wrong shopper. Calling the API on every request gives AI Commerce Search the real-time behavioral signals needed to lift relevance and conversions.

Portrait of Sebastian Hooker

Sebastian Hooker · Managing Partner, Nimstrata

Updated


Calling Google Cloud's Retail API on every search, filter, sort, and browse request is essential for getting full value from Google Cloud's AI Commerce Search (formerly Vertex AI Search for commerce). While caching responses from a pay-per-request API can look like an easy way to trim costs, caching starves the AI models of live shopper signals and risks serving personalized results to the wrong visitor.

Costs

Let’s get pricing out of the way first. Yes, it costs more to do this. However, the AI model performance will be better, and if your product catalog is optimized, then it will lead to more top-line revenue. Assuming your AI Commerce Search project had a meaningful ROI and business case to begin with, the cost to send additional API calls should be negligible compared to the up-lift in average order value and conversion rates you should see as a result of implementing the technology. Don’t spend a dollar to save a nickel!

A Real-World Example: Filtering

To understand why this is important, let's review how filtering and improving search results works:

When you call the AI Commerce Search endpoint with a user’s search query and receive a search results page, a JSON response is delivered - this includes products in a specific order and dynamic facets.

Once you have this JSON object, it can be tempting to complete all on-page filtering client-side in the browser. If it's a common search term, you may even cache the results for this specific query behavior and skip calling the Retail API altogether. While it's tempting to avoid creating additional latency when users are simply filtering and sorting products, the user behavior provides valuable feedback to train the search and recommendations models. However, this does assume that you're correctly sending user events back to the Retail API—a topic we break down in our guide to user events for AI Commerce Search.

If users consistently filter by the same attribute (like size) and attribute value (like medium) on every search for, “blue t-shirts” then AI Commerce Search will not only learn to start placing Size at the top of the dynamic facets, but also put more medium shirts earlier in the search results by default - assuming these users also convert!

This clever logic is an ongoing training process and can take place on thousands of queries, outperforming even the best human merchandisers.

Performance

If you’re using AI Commerce Search to serve browse results on your storefront, you may be switching from a CDN-delivered category page to a Retail API-delivered category page instead.

Images, typically the most bandwidth-intensive retrieval, can still be delivered via a CDN. The image URI uploaded with your product data can be a CDN-delivered path.

The closer your ecommerce solution is hosted to Google Cloud, the better. If your solution is hosted on-premises and needs to make an API call to Google every time a page loads, minimizing latency is crucial. A dedicated or partner interconnect can help with this.

Caching

You should never cache personalized results from an end user to prevent returning personalized results to a different end user.

When deploying Google Cloud's AI Commerce Search on your ecommerce website for the first time, be sure you fully document and understand your content delivery data flow. For example, if you're using a CDN such as Cloudflare, you may find that the default cache behavior or configured rules alter search result responses—something to watch for alongside your Retail API configuration settings.

Even if you don’t explicitly have caching enabled at the common layers of your application, it’s pretty amazing where unintended caching behavior can occur!

Segment Bot Traffic

If you have implemented client-side loading or a CDN due to bot traffic, it may be time to filter bot traffic to another search solution - preferably a free one. Calls made to the Retail API are not delineated between human and bot traffic, which means you may end up paying for bots to scrape your website. Like some bacteria in your body, some bots, like a search engine indexer, can be good!

Be careful though, bots can create unintended model training results by making searches or browse requests but never converting.

Why Per-Request Retail API Calls Pay Off

Following this implementation guidance when activating AI Commerce Search and Recommendations AI should help you get the best top-line revenue results while minimizing costs and performance tradeoffs. The additional Retail API costs should be offset by increased revenue, and fully understanding how data flows between your infrastructure and your end users will help you design a thoughtful solution. If you are planning a custom architecture or launching on Shopify, explore Nimstrata's AI Commerce Search implementations or Retail Cloud Connect.

Related Guides

FAQ

Common Questions

Why shouldn't I cache Google Cloud Retail API search and browse results?

Caching Retail API responses prevents AI Commerce Search from observing live filtering, sorting, and query behavior that trains its ranking and dynamic faceting models. It also creates a risk of serving one shopper's personalized results to another visitor.

Should I run facet filtering client-side in the browser to reduce Retail API calls?

No. Handling filtering client-side skips sending filter interactions back through the Retail API. When paired with proper user event tracking, server-side Retail API filter calls teach the models which attributes and values drive conversions so they can rank those facets and products higher automatically.

How can I keep latency low if I call the Retail API on every page request?

Continue serving bandwidth-heavy product images from your CDN by storing CDN paths in each product's image URI, host your ecommerce backend close to Google Cloud regions, and consider Dedicated or Partner Interconnect if your store runs on-premises.

How does bot traffic impact Google Cloud Retail API costs and model quality?

The Retail API does not separate human shoppers from bots, so unsegmented crawler traffic increases per-request billing and can distort model training by generating search and browse requests that never convert. Route non-human bot traffic to a separate, lower-cost search path.

Get Started

See Google’s AI Commerce Search on your store

Install the Shopify app, or book a demo to see it on your catalog.