Skip to main content

Prerequisites

  • Bun (recommended) or Node.js
  • Docker and Docker Compose
  • API keys for the AI providers you want to use (Anthropic, OpenAI, or Google)

Setup

1

Clone the repository

2

Install dependencies

3

Start local services

This starts PostgreSQL, Redis, and MinIO (S3-compatible storage):
4

Configure environment variables

Edit /.env and fill in your API keys and configuration. At minimum you need:
  • DATABASE_URL — PostgreSQL connection string
  • REDIS_URL — Redis connection string
  • ANTHROPIC_API_KEY — For Claude
  • BETTER_AUTH_SECRET — Authentication secret
  • BAP_CLOUD_API_BASE_URL — Bap Cloud base URL for delegated login
  • BAP_CLOUD_INSTANCE_API_KEY — Shared control-plane instance key
5

Set up the database

Push the schema to your database:
Optionally seed with initial data:
6

Start the app

This starts the web app, worker, and WS runtime from the monorepo root. The web app will be available at http://localhost:3000.

Docker Compose (all-in-one)

For a fully containerized setup backed by published GHCR images (app + worker + DB + Redis + MinIO), use the bundled compose file at docker/compose/selfhost.yml:
Fill in at least:
  • APP_URL
  • BETTER_AUTH_SECRET
  • ENCRYPTION_KEY
  • BAP_SERVER_SECRET
  • BAP_CLOUD_API_BASE_URL
  • BAP_CLOUD_INSTANCE_API_KEY
  • OPENAI_API_KEY
  • ANTHROPIC_API_KEY
Optionally pin the image tags in /.env.selfhost:
Then pull, migrate, and start:
Then open http://localhost:8114. Self-hosted end-user login is delegated to Bap Cloud. Configure the same BAP_CLOUD_INSTANCE_API_KEY on the cloud deployment and on each self-hosted deployment that should trust it.
  • Set E2B_API_KEY and E2B_DAYTONA_SANDBOX_NAME to use E2B cloud sandboxes.
  • Or set DAYTONA_API_KEY (plus optional DAYTONA_API_URL / DAYTONA_SERVER_URL / DAYTONA_TARGET) to use Daytona sandboxes.
  • Or set SANDBOX_DEFAULT=docker to use local Docker-based sandboxes.
  • Published images also get a daily YYYYMMDD-N tag such as 20260310-1.
  • Use a sha-... tag instead of main if you want to test a specific published build.
  • The published app image does not include custom browser-side VITE_POSTHOG_* values; build docker/images/web/Dockerfile yourself if you need them.

Background worker

Bap uses BullMQ for generation execution and background jobs. Chat and coworker runs are executed by the worker, so start it in a separate terminal:
This command loads /.env so the worker uses the same local environment as bun dev.

WebSocket server

The WebSocket server still runs separately from the web app:
This command also loads /.env.

Useful commands

Tech stack