Example Next.js project with Thesys GenUI SDK, showing how to persist chat history, threads.
- copy .env.example to .env and set the THESYS_API_KEY
cp .env.example .env
- install dependencies:
npm installThen, run the development server:
npm run dev├── src/
│ ├── app/
│ │ ├── api/ # API routes
│ │ ├── page.tsx # Main page component
│ │ ├── layout.tsx # Root layout
│ │ └── globals.css # Global styles
│ ├── generated/ # Generated code
│ ├── services/ # Service layer
│ └── apiClient.ts # API client configuration
├── prisma/ # Database schema and migrations
├── public/ # Static assets
├── .env # Environment variables
├── example.env # Example environment variables
├── next.config.ts # Next.js configuration
├── package.json # Project dependencies
├── tsconfig.json # TypeScript configuration
└── README.md # Project documentation
This example is a simple chat application built with Next.js, Thesys GenUI SDK, and Prisma. It allows users to have conversations with an AI assistant, and persist the chat history.
What is the weather in New York?
only 1 tool is supported:
{
"location": "New York, NY"
}
See: src/app/page.tsx for the usage of useThreadManager and useThreadListManager to fetch the chat history on render and other integrations with backend apis.
Checkout the backend code in:
src/app/api/chat/route.tsfor the usage of the api/chat route to handle the tool call and persist the chat history.src/app/api/threadandsrc/app/api/threadsfor Thread and Message CRUD