Skip to Content
Getting StartedSelf-Hosting

Self-Hosting

Deploy the full Kaizen stack with Docker or Podman.

Clone the repository

git clone <repo-url> kaizen cd kaizen

Configure your environment

Copy the example environment file and fill in your settings:

cp .env.example .env

Edit .env with the following variables:

VariableDefaultDescription
DATABASE_URLpostgresql+psycopg://postgres:postgres@postgres:5432/continuous_tunePostgreSQL connection string
REDIS_URLredis://redis:6379/0Redis connection string
OPENAI_API_KEYRequired. Your LLM provider API key
TEACHER_MODELgpt-4oModel used by DSPy for generating few-shot examples
JUDGE_MODELgpt-4o-miniModel used for LLM-as-judge evaluation
GIT_PROVIDERgithubGit provider: github, bitbucket_server, or gitlab
GIT_TOKENFine-grained PAT or access token for auto-PR
GIT_REPOTarget repository (e.g., your-org/your-repo)
GIT_BASE_BRANCHmainBranch to target for pull requests

The GIT_* variables are only required if you want auto-PR functionality. Kaizen works without them — you can manually activate optimized prompts.

Start the stack

# With Podman podman-compose up -d # Or with Docker docker compose up -d

This starts the following services:

ServicePortPurpose
api8000FastAPI REST API
dashboard3000Web UI for monitoring jobs, scores, and prompts
docs4000Documentation site (this site)
flower5555Celery task monitoring dashboard
postgres5432Persistent storage for tasks, feedback, prompts, jobs
redis6379Prompt cache, Celery broker, and auto-trigger dedup lock
workerCelery worker running DSPy optimization

Create your first API key

Bootstrap an API key using the one-time bootstrap endpoint:

curl -X POST http://localhost:8000/api/v1/keys/bootstrap \ -H 'Content-Type: application/json' \ -d '{"name": "dev-key"}'

The response contains your API key:

{ "id": "uuid-here", "name": "dev-key", "key": "kaizen_abc123...", "created_at": "2026-01-01T00:00:00Z" }

Save the key value immediately — it is only shown once. The API stores a SHA-256 hash and cannot recover the plaintext. The bootstrap endpoint auto-disables after the first key is created.

Verify the deployment

Check that the API is running:

curl http://localhost:8000/health

Expected response:

{"status": "ok"}

You can also verify the dashboard at http://localhost:3000  and the docs at http://localhost:4000 .

Environment variable reference

For a complete list of configuration options, see the table below:

CategoryVariableDefaultDescription
DatabaseDATABASE_URLpostgresql+psycopg://...PostgreSQL connection
CacheREDIS_URLredis://redis:6379/0Redis connection
CachePROMPT_CACHE_TTL300Prompt cache TTL in seconds
LLMOPENAI_API_KEYLLM provider API key
LLMOPENAI_API_BASECustom LLM endpoint URL
LLMSSL_VERIFYtrueVerify SSL for LLM calls
OptimizationTEACHER_MODELgpt-4oDSPy teacher model
OptimizationJUDGE_MODELgpt-4o-miniEvaluation judge model
OptimizationCOST_BUDGET_DEFAULT5.0USD budget per optimization run
OptimizationMAX_TRIALS_DEFAULT15Maximum MIPROv2 trials
OptimizationLLM_TIMEOUT120HTTP timeout for LLM calls (seconds)
OptimizationOPTIMIZATION_WALL_TIMEOUT1800Wall-clock timeout (seconds)
GitGIT_PROVIDERgithubgithub, bitbucket_server, or gitlab
GitGIT_BASE_URLBase URL for self-hosted Git (e.g., Bitbucket Server)
GitGIT_TOKENAccess token for auto-PR
GitGIT_PROJECTBitbucket Server project key
GitGIT_REPOTarget repository
GitGIT_BASE_BRANCHmainPR target branch
LimitsFEEDBACK_RETENTION_LIMIT1000Max feedback entries per task
LimitsSEED_SIZE_LIMIT1000Max seed entries per upload

Next steps

Last updated on