
Deploy Web UI - kie.ai
Deploy and Host KIE AI Image Generator with Railway
Just deployed
Deploy and Host KIE AI Image Generator on Railway
A self-hosted AI image generation web app powered by the KIE.ai API, with Cloudflare R2 storage and a responsive gallery. Generate images from text prompts, track progress in real time, and browse everything you've created in one place.
About Hosting KIE AI Image Generator on Railway
The app runs as a single Dockerized Next.js service. SQLite (via Drizzle ORM) handles task/image metadata inside the container, while generated images are uploaded to a Cloudflare R2 bucket you provide. Railway builds the Docker image, provisions the public HTTPS domain, and keeps the service running — you just supply your KIE.ai and R2 credentials.
Tech Stack
- Next.js (App Router, TypeScript)
- shadcn/ui + Tailwind CSS
- Drizzle ORM + SQLite (
better-sqlite3) - Cloudflare R2 (S3-compatible storage)
- SWR for real-time task polling
Why Deploy
- Text-to-image generation via the KIE.ai API (SeeDream 4.5, extensible to other models)
- Real-time progress — polls task status and auto-updates when the KIE.ai callback fires
- Gallery — paginated grid of every generated image with full-size view, download, and delete
- Optional password gate — lock the app down with
ADMIN_PASSWORDif you're hosting it for yourself - Flexible model registry — add new KIE.ai models by editing one file, no UI changes needed
Dependencies for KIE AI Image Generator
Deployment Dependencies
- A KIE.ai account and API key
- A Cloudflare R2 bucket (S3-compatible object storage) for generated images
Required Environment Variables
| Variable | Description |
|---|---|
KIE_API_KEY | Your KIE.ai API key |
NEXT_PUBLIC_APP_URL | Public URL of this deployment (used for KIE.ai callbacks) — set this to your Railway-generated domain |
R2_ACCOUNT_ID | Cloudflare account ID |
R2_ACCESS_KEY_ID | R2 access key |
R2_SECRET_ACCESS_KEY | R2 secret key |
R2_BUCKET_NAME | R2 bucket name |
R2_PUBLIC_URL | Public URL of your R2 bucket (custom domain or r2.dev subdomain) |
ADMIN_PASSWORD | Optional password gate for the app |
AUTH_SECRET | Required if ADMIN_PASSWORD is set — secret used to sign the session cookie |
Getting Started
- Deploy the template and fill in the required variables above.
- Once the service shows a green "Success" status, copy its public domain and set it as
NEXT_PUBLIC_APP_URL(redeploy after changing it, since KIE.ai callbacks depend on it). - Open the deployed URL, enter a prompt, and generate your first image.
- Visit
/galleryto browse everything you've generated.
Common Use Cases
- Personal AI image generation tool without per-seat SaaS pricing
- Prototyping prompts against KIE.ai models with a proper UI instead of raw API calls
- Small team/internal tool for generating marketing or creative assets
Source
- Repository: github.com/zahidakhyar/web-ui-kie-ai
- License: MIT
Template Content
KIE_API_KEY
Your KIE.ai API key
R2_ACCOUNT_ID
Cloudflare account ID
ADMIN_PASSWORD
Password gate for the app (leave unset to disable auth)
R2_BUCKET_NAME
R2 bucket name
R2_ACCESS_KEY_ID
R2 access key
NEXT_PUBLIC_APP_URL
Public URL of this app (for callbacks)
R2_SECRET_ACCESS_KEY
R2 secret key
