How It Works

Behind the scenes of the agentic shopping experience

Architecture Overview

This demo lets you search for products using natural language. Under the hood it uses Exa's category: "product" search to find product pages, then extracts structured price and currency data from AI-generated summaries.

1

Natural Language Query

You type a product query in plain English — 'wireless noise cancelling headphones under $300', 'best running shoes for flat feet', etc.

2

Product Search

Exa's product category routes the query through a product-specific search pipeline that automatically identifies and prioritizes product pages.

3

Structured AI Summary

Each result gets an AI-generated summary with a JSON schema enforcing structured fields: description, price (numeric), and currency (ISO 4217 code).

4

Product Cards

The structured data is rendered into product cards showing the image, title, price with currency symbol, description, and a link to the source.

Exa Search Call

The core API call uses category: "product" with richImageLinks for intelligent image selection, plus a summary schema for structured price extraction.

// Step 1: Search for product pages with rich images
const searchResponse = await exa.search(query, {
  type: "auto",
  numResults: 20,
  category: "product",
  contents: {
    extras: { richImageLinks: 5, imageLinks: 1 },
  },
});

// Step 2: Get structured price/currency via contents.summary
const urls = searchResponse.results.map(r => r.url);
const contentsResponse = await exa.getContents(urls, {
  summary: {
    query: "Product details for: ...",
    schema: { /* price + currency schema */ },
  },
  text: true,
});

Structured Summary Schema

The summary schema enforces a JSON response with typed fields. The AI extracts price as a number and currency as an ISO 4217 code, making it easy to format consistently.

{
  "type": "object",
  "properties": {
    "description": {
      "type": "string",
      "description": "A concise one-sentence description"
    },
    "price": {
      "type": "number",
      "description": "Numeric price without currency symbol"
    },
    "currency": {
      "type": "string",
      "description": "ISO 4217 currency code (USD, EUR, GBP)"
    }
  },
  "required": ["description"],
  "additionalProperties": false
}