A chat app that generates images using Replicate and Cloudflare Workers.
Kontext Chat is powered by FLUX.1 Kontext Pro, a new image model from Black Forest Labs, running on Replicate. The app is built with Hono and React and it deployed on Cloudflare Workers.
See kontext-chat.replicate.dev for a live demo.
-
Install dependencies:
npm install
-
Get a Replicate API Token:
- Sign up at https://replicate.com/ and get your REPLICATE_API_TOKEN from your account settings at https://replicate.com/account/api-tokens.
-
Set up your local environment:
- Create a .dev.vars file in the project root (already present in this repo) and add your token:
REPLICATE_API_TOKEN=your-token-here
- Create a .dev.vars file in the project root (already present in this repo) and add your token:
-
Start the local dev server:
npm run dev
- The app will be available at http://localhost:8787 by default.
-
Authenticate Wrangler:
npx wrangler login
-
Set your Replicate API token as a secret:
npx wrangler secret put REPLICATE_API_TOKEN
-
Deploy:
npm run deploy
- Your app will be deployed to your Cloudflare Workers account.
- The frontend is served from the public/ directory.
- The backend is a Cloudflare Worker (entry: src/index.ts).
- The app requires a valid REPLICATE_API_TOKEN to function.