MkImage
Learn how to deploy MkImage - an AI image generation website built on TanStarter
MkImage is an AI image generation website built on the TanStarter template. The source code is available at mkfast-app.
Since MkImage is built on TanStarter, the configuration and deployment process is essentially the same as the template. Please refer to the Getting Started, Environment Configuration, and Deployment guides for the base setup.
This guide focuses on the additional configuration specific to MkImage.
AI Image Model Provider
MkImage supports two AI image generation providers. You need to register an account and generate an API key from their dashboard.
Fal.ai is a fast inference platform for AI models.
- Create an account at fal.ai
- Go to the API Keys page in your dashboard
- Click Create API Key to generate a new key
- Copy the key and set it as the
FAL_KEYenvironment variable
IMAGE_MODEL_PROVIDER='fal'
FAL_KEY='your-fal-api-key'APIMart is an API marketplace that provides access to various AI models.
- Create an account at apimart.com
- Go to the API Keys management page in your dashboard
- Generate a new API key
- Copy the key and set it as the
APIMART_KEYenvironment variable
IMAGE_MODEL_PROVIDER='apimart'
APIMART_KEY='your-apimart-api-key'Additional Image Generation Settings
| Variable | Description |
|---|---|
| IMAGE_MODEL_PROVIDER | Image generation provider: fal or apimart |
| VITE_SHOW_IMAGE_PROVIDER | Show provider selector in generate page (true/false) |
| VITE_ENABLE_IMAGE_GENERATION | Enable image generation feature (true/false) |
Storage (Cloudflare R2)
MkImage uses Cloudflare R2 to store prompt data and prompt preview images. You need to configure R2 to import and serve this content.
Create Cloudflare R2 Bucket
- Create a Cloudflare account at cloudflare.com
- Create a new R2 bucket:
- Pick a globally unique bucket name (e.g.,
mkimage-prompts) - Select a region close to your target audience
- Pick a globally unique bucket name (e.g.,
Enable Public Access
Allow public access to the bucket:
Settings>Public Development URL, clickEnable- Save the public access URL as
R2_PUBLIC_URL - Set custom domains for public access to the bucket (recommended for security)
Create API Token
Create a new API Token:
Storage & databases>R2 object storage>API Tokens>Manage, clickCreate User API Token- Set permissions to
Object Read & Writeto the bucket - Create the API Token, get the
Access Key IDandSecret Access Key
Set Environment Variables
Set the following environment variables:
R2_BUCKET_NAME='your-bucket-name'
R2_ACCESS_KEY_ID='your-access-key-id'
R2_SECRET_ACCESS_KEY='your-secret-access-key'
R2_PUBLIC_URL='https://your-r2-public-url.com'Import Built-in Prompts
MkImage includes a built-in prompt dataset that you can import into your database. The import script syncs prompt data and preview images to your D1 database and R2 storage.
Apply Database Migrations
Make sure the prompt-related database tables are created:
# Local development
pnpm db:migrate:local
# Remote / production
pnpm db:migrate:remoteSync Prompts to Local
Import prompts into your local D1 database and R2 storage:
pnpm prompts:sync:localThis will insert prompt records into the database and upload preview images to R2.
Sync Prompts to Remote (Production)
After verifying locally, sync prompts to your remote production environment:
pnpm prompts:sync:remoteUseful Flags
The sync script supports several optional flags:
| Flag | Description |
|---|---|
--limit=<n> | Only import the first N rows (useful for testing) |
--skip-images | Skip image download/upload (text-only import) |
--force | Re-import even if prompt already exists |
--dry-run | Preview changes without writing to DB/R2 |
--concurrency=<n> | Number of parallel imports (default: 10) |
Updating Prompts
To update the prompt dataset in the future:
# Pull latest dataset
pnpm prompt:download
# Re-sync locally first
pnpm prompts:sync:local
# After confirming, sync to production
pnpm prompts:sync:remoteExisting prompts are skipped by default. Only new prompts and missing media are imported unless you pass --force.
Environment Variables Summary
Here is the full list of MkImage-specific environment variables to add on top of the base TanStarter configuration:
# Image Generator (apimart or fal)
IMAGE_MODEL_PROVIDER='apimart'
VITE_SHOW_IMAGE_PROVIDER='false'
VITE_ENABLE_IMAGE_GENERATION='true'
# Fal
FAL_KEY=''
# APIMart
APIMART_KEY=''
# Storage (R2) - for prompts and prompt images
R2_BUCKET_NAME=''
R2_ACCESS_KEY_ID=''
R2_SECRET_ACCESS_KEY=''
R2_PUBLIC_URL=''
TanStarter Docs