Getting started
Let’s build an AI shopping assistant that can analyze real purchases history and make personalized recommendations. Create an API key for both Subtotal and OpenAI if you haven’t already.Create a new Next.js project
Create a new Next.js project named with TypeScript and the App Router:Install dependencies
Install theSubtotal AI Toolkit
and OpenAI AI SDK
packages:
Configure environment variables
Create a.env.local
file and add your API keys:
Create the chat interface
Replace the contents ofsrc/app/page.tsx
with the following code:
Integrate with Subtotal and OpenAI
Create a new filesrc/app/api/chat/route.ts
and add the following code: