Self-hosting
Run the Kaimei API on your own infrastructure, against SQLite on a laptop or Postgres for a team.
The API is a FastAPI service and runs anywhere Python 3.9 does, against SQLite for a laptop or Postgres (Supabase works) for a team. Enterprise plans include a private deployment; the configuration below applies to any installation.
Configuration is through KAIMEI_* environment variables or a .env file in the working directory. The ones that matter most:
| Variable | Default | Meaning |
|---|---|---|
KAIMEI_DATABASE_URL | sqlite:///./kaimei.db | SQLAlchemy URL. Postgres in production. |
KAIMEI_SECRET_KEY | (dev value) | HMAC key for session tokens. At least 32 random bytes; always set it. |
KAIMEI_ENV | development | production turns email verification on by default; test turns rate limits and quotas off. |
KAIMEI_PUBLIC_API_URL / KAIMEI_DASHBOARD_URL | localhost | Used for OAuth callbacks, verification links and CORS. |
KAIMEI_ALLOW_SIGNUP | true | Set false for an invite-only installation. |
KAIMEI_MAX_REFERENCE_ROWS | 5000 | Reference rows kept per model. |
KAIMEI_EXPLANATION_EVAL_BUDGET | 60000 | Soft ceiling on model evaluations per explanation. |
KAIMEI_IMAGE_EXPLAIN_SECONDS | 40 | Time budget image explanations plan their grid to fit. |
KAIMEI_MAX_TENSOR_BYTES | 536870912 | Largest single binary tensor upload, compressed. |
KAIMEI_REMOTE_INFERENCE_TIMEOUT_S | 30 | Default timeout for remote endpoints. |
KAIMEI_BEHIND_CLOUDFLARE / KAIMEI_TRUST_PROXY | false | Read the client IP from CF-Connecting-IP / X-Forwarded-For for rate limits. |
KAIMEI_TURNSTILE_* , KAIMEI_SMTP_*, KAIMEI_GOOGLE_* , KAIMEI_GITHUB_* | unset | Bot protection on sign-up, verification email, OAuth sign-in. |
Point the Python client at your installation with base_url or KAIMEI_BASE_URL; the dashboard with VITE_API_URL.
shell
pip install -e ".[dev]" # from the kaimei API repository
kaimei-api init-db # create tables
kaimei-api seed-demo # [email protected] / kaimei-demo, five reference models, an API key
kaimei-api serve --reload # http://localhost:8000, interactive docs at /docs
kaimei-api openapi -o openapi.json # the OpenAPI schema
# Postgres / Supabase
pip install -e ".[postgres]"
export KAIMEI_DATABASE_URL=postgresql://postgres.[ref]:[password]@aws-0-[region].pooler.supabase.com:5432/postgres
kaimei-api migrate-db --inspect # row counts in the local SQLite file
kaimei-api migrate-db # copy it over