This repository contains a few advanced examples, which serve a complete ChatKit playground that pairs a FastAPI backend with a Vite + React frontend.
The top-level backend and frontend directories provide a basic project template that demonstrates ChatKit UI, widgets, and client tools.
- It runs a custom ChatKit server built with ChatKit Python SDK and OpenAI Agents SDK for Python.
- Available agent tools focus on caring for the virtual cat: status checks, feeding, playtime, cleaning, name selection, and a profile widget, plus client tools for switching the UI theme, updating the dashboard stats, and triggering cat speech bubbles.
The Vite server proxies all /chatkit traffic straight to the local FastAPI service so you can develop the client and server in tandem without extra wiring.
- Start FastAPI backend API.
- Configure the frontend's domain key and launch the Vite app.
- Explore the demo flow.
Each step is detailed below.
From the repository root you can bootstrap the backend in one step:
npm run backendThis command runs uv sync for backend/ and launches Uvicorn on http://127.0.0.1:8000. Make sure uv is installed and OPENAI_API_KEY is exported beforehand.
If you prefer running the backend from inside backend/, follow the manual steps:
cd backend
uv sync
export OPENAI_API_KEY=sk-proj-...
uv run uvicorn app.main:app --reload --port 8000If you don't have uv, you can do the same with:
cd backend
python -m venv .venv && source .venv/bin/activate
pip install -e .
export OPENAI_API_KEY=sk-proj-...
uvicorn app.main:app --reloadThe development API listens on http://127.0.0.1:8000.
From the repository root you can start the frontend directly:
npm run frontendThis script launches Vite on http://127.0.0.1:5170.
To configure and run the frontend manually:
cd frontend
npm install
npm run devOptional configuration hooks live in frontend/src/lib/config.ts if you want to tweak API URLs or UI defaults.
To launch both the backend and frontend together from the repository root, you can use npm start. This command also requires uv plus the necessary environment variables (for example OPENAI_API_KEY) to be set beforehand.
The Vite dev server runs at http://127.0.0.1:5170, and this works fine for local development. However, for production deployments:
- Host the frontend on infrastructure you control behind a managed domain.
- Register that domain on the domain allowlist page and add it to
frontend/vite.config.tsunderserver.allowedHosts. - Set
VITE_CHATKIT_API_DOMAIN_KEYto the value returned by the allowlist page.
If you want to verify this remote access during development, temporarily expose the app with a tunnel (e.g. ngrok http 5170 or cloudflared tunnel --url http://localhost:5170) and add that hostname to your domain allowlist before testing.
With the app reachable locally or via a tunnel, open it in the browser and try a few interactions. Each ChatKit thread maintains its own cat state (energy, happiness, cleanliness, name, and age), so switching threads gives every conversation a unique pet without leaking stats between them. That per-thread state is what powers the meters, flash messages, and widgets on the dashboard.
Try these prompts:
Please give the cat a snackorPlay with the cat for a few minutes- invokes thefeed_catorplay_with_catserver tool calls followed by theupdate_cat_statusclient tool call to update the cat's stats and render the new values.I want to name the cat- if you don't specify a name, the agent callssuggest_cat_namesto render an interactive widget; picking an option fires thecats.select_nameaction, persists the name on the server, and retitles the thread for that cat going forward.Name the cat Mr. Whiskers- invokes theset_cat_nameserver tool call to update the cat's profile and the thread title, followed by theupdate_cat_statusclient tool call to reflect the changes client-side.Show me the cat's profile card- theshow_cat_profiletool renders a static widget using the current cat name.Hi, cat!- thespeak_as_cattool invokes thecat_sayclient tool call to render a speech bubble for the cat.
Quick actions:
- Quick action buttons will send prompts on the user's behalf using ChatKit's
sendUserMessagecommand.
Under the examples directory, you'll find three more sample apps that ground the starter kit in real-world scenarios:
- Customer Support: airline customer support workflow.
- Knowledge Assistant: knowledge-base agent backed by OpenAI's File Search tool.
- Marketing Assets: marketing creative workflow.
Each example under examples/ includes the helper scripts (npm start, npm run frontend, npm run backend) pre-configured with its dedicated ports, so you can cd into an example and run npm start to boot its backend and frontend together. Please note that when you run npm start, uv must already be installed and all required environment variables should be exported.