# Environment variables

Every setting of the server, the worker, the CLI and your app's backend.

Source: https://clipmux.com/docs/reference/configuration

Every setting is an environment variable; nothing is read from a file except
the keys serve keeps under `CLIPMUX_DATA_DIR`. The repository's `.env.example`
lists each variable with an example. A test fails when the server reads a
variable this page doesn't name, so the list is complete.

A value that doesn't parse stops the command at start, naming the variable.

## clipmux serve [#clipmux-serve]

| Variable | Default | What it does |
| --- | --- | --- |
| `DATABASE_URL` | required | Postgres. pgxpool options go in the URL (`pool_max_conns=20`); session settings too (`statement_timeout=30s`). Unset, every session gets `statement_timeout=60s` and `idle_in_transaction_session_timeout=5min`. serve waits up to a minute for Postgres at boot. |
| `CLIPMUX_LISTEN` | `:8080` | Where serve listens. Behind Caddy, keep it off the public interface. |
| `CLIPMUX_DATA_DIR` | `./data` | Filesystem storage, the storage signing key, and the secrets key when `CLIPMUX_SECRETS_KEY` is unset. Back it up. |
| `CLIPMUX_SECRETS_KEY` | `{data_dir}/secrets.key` | `v1:` and 64 hex digits; seals every secret kept in Postgres. Losing it makes every stored secret, and every output, unusable. |
| `CLIPMUX_SECRETS_KEY_PREVIOUS` | unset | The key being rotated away from, only until `clipmux admin reseal-secrets` has run. |
| `CLIPMUX_BACKUP_URL` | `file://{data_dir}/backups` | Where backups go: `s3://bucket/prefix?endpoint=https://…&region=…` for an S3-compatible bucket (Backblaze B2, R2, S3), or `file:///absolute/path`. The default is the server's own disk. |
| `CLIPMUX_BACKUP_ACCESS_KEY_ID`, `CLIPMUX_BACKUP_SECRET_ACCESS_KEY` | unset | The bucket's credentials; required for an `s3://` target. Use a key that can write and list but not delete. |
| `CLIPMUX_BACKUP_INTERVAL` | `1h`; `24h` for the default directory | Time between scheduled backups, a duration of at least `1m`. `0` turns scheduled backups off; `clipmux admin backup now` still works. |
| `CLIPMUX_BACKUP_RECIPIENTS` | none | More age recipients (`age1…`, comma-separated) every backup is encrypted to, such as a key you keep offline. |
| `CLIPMUX_BACKUP_PING_URL` | unset | A URL fetched after each successful scheduled backup, for a dead man's switch such as healthchecks.io or an Uptime Kuma push monitor. |
| `CLIPMUX_BACKUP_BEFORE_MIGRATE` | `true` | Back the database up (kind `pre_migrate`) before applying pending migrations, at boot and in `clipmux admin` commands, and refuse to migrate if the backup fails. `false` migrates without one. A new database has nothing to back up. |
| `CLIPMUX_PG_DUMP` | `pg_dump` on `PATH` | The PostgreSQL 18 `pg_dump` backups run. The image has it. |
| `CLIPMUX_PUBLIC_URL` | chosen at first boot | The origin browsers and workers reach serve at. Set, it pins both URLs and the first-boot URL step is read-only. |
| `CLIPMUX_MEDIA_URL` | `CLIPMUX_PUBLIC_URL` | The origin playback is served from (`base_url`); ideally another registrable domain. Needs `CLIPMUX_PUBLIC_URL`. |
| `CLIPMUX_TRUSTED_PROXIES` | none | Addresses or CIDR ranges (Caddy's) whose `X-Forwarded-For`, `X-Forwarded-Proto` and `X-Request-Id` are believed. Rate limits, sign-in limits, request IDs and the https redirect all depend on it. |
| `CLIPMUX_MAX_UPLOAD_BYTES` | the storage limit (~312 GiB) | The largest declared upload. |
| `CLIPMUX_BUILTIN_WORKER` | `true` | Start `clipmux worker` as serve's child. |
| `CLIPMUX_UNSANDBOXED_WORKER` | `false` | Run the built-in worker where the media tool sandbox or Landlock doesn't hold. Only if the host isolates it another way. Where only Landlock is missing, the tools keep seccomp and the limits. |
| `CLIPMUX_TOOL_MEMORY_MB` | `8192` | Memory limit for each media tool. Passed to the built-in worker. |
| `CLIPMUX_FFMPEG`, `CLIPMUX_FFPROBE`, `CLIPMUX_PACKAGER`, `CLIPMUX_WHISPER` | found on `PATH` | The media tools. Shaka Packager must be 3.9.1 or later; `whisper-cli` is the pinned whisper.cpp from `toolchain/build_whisper.sh`, used only to transcribe. |
| `CLIPMUX_LOG_FORMAT` | `text` | `text` or `json`. Passed to the built-in worker. |
| `CLIPMUX_LOG_LEVEL` | `info` | `debug`, `info`, `warn` or `error`. Successful playback, storage and worker requests log at debug. |
| `CLIPMUX_METRICS_ADDR` | unset (off) | `host:port` for `/metrics`, a listener of its own with no auth: keep it off the internet. |
| `CLIPMUX_PPROF` | `false` | Add Go's `/debug/pprof/` to the metrics listener. Needs `CLIPMUX_METRICS_ADDR`. |
| `CLIPMUX_SELF_DIAL` | unset | Where the setup test connects for every URL it checks, keeping each URL's hostname (compose: `caddy`). |
| `CLIPMUX_CLOUDFLARE_API` | Cloudflare's v4 API | Cloudflare's API base, for a proxy or a test double. |
| `CLIPMUX_R2_ENDPOINT` | `https://{account_id}.r2.cloudflarestorage.com` | R2's S3 endpoint, e.g. the EU jurisdiction's. |
| `CLIPMUX_RUNPOD_API` | RunPod's v2 REST API | RunPod's API base, for a test double. |
| `CLIPMUX_RUNPOD_CATALOG` | RunPod's v2 API | Where RunPod's GPU prices come from, for a test double. |
| `CLIPMUX_WORKER_IMAGE` | the image this build names | The image RunPod and Modal machines run. |
| `CLIPMUX_EXECUTORS_ALLOW_PRIVATE_URL` | `false` | Connect RunPod or Modal while the public URL is private: development only. |

## clipmux worker [#clipmux-worker]

A PC agent paired with `--pair` keeps its server and key in `agent.json` and
needs none of these; the built-in worker gets its own from serve.

| Variable | Default | What it does |
| --- | --- | --- |
| `CLIPMUX_SERVER` | from `agent.json` | The server's public URL. |
| `CLIPMUX_WORKER_KEY` | from `agent.json` | The worker's key. Never in argv. |
| `CLIPMUX_AGENT_DIR` | the user's config directory | Where `agent.json`, `sources.json` and `agent.sock` live. |
| `CLIPMUX_ENCODER` | `auto` | The first encoder to try: `auto`, `nvenc`, `vaapi`, `cuda-decode` or `cpu`. |
| `CLIPMUX_VAAPI_DEVICE` | every `/dev/dri/renderD*` | The VAAPI render node. |
| `CLIPMUX_SPEECH` | `auto` | Whether the worker transcribes subtitles: `auto` (on a GPU whose probe passes, CUDA first and then Vulkan, else on a CPU with at least 4 cores and 6 GiB), `off`, `cpu`, `vulkan` or `cuda`. serve passes it to the built-in worker. |
| `CLIPMUX_FOLLOW_ON_SPEECH` | unset | Set by serve on a serverless machine woken for an encode, never by hand: the speech mode (`auto`) it proves speech in if serve hands it the asset's transcription after the encode. `off` or unset: it takes no transcription. |
| `CLIPMUX_BAKED_MODELS_DIR` | `/usr/share/clipmux/models` in the image; unset elsewhere | The speech models baked into the image. A worker uses them when they are there, and downloads nothing. serve passes it to the built-in worker. |
| `CLIPMUX_MODELS_DIR` | `models/` in `CLIPMUX_AGENT_DIR`; the built-in worker's is `models/` in serve's data directory | Where a worker without baked models keeps the speech models it downloads by digest (about 0.9 GB), across restarts. |
| `CLIPMUX_TOOL_MEMORY_MB`, `CLIPMUX_FFMPEG`, `CLIPMUX_FFPROBE`, `CLIPMUX_PACKAGER`, `CLIPMUX_WHISPER`, `CLIPMUX_LOG_FORMAT`, `CLIPMUX_LOG_LEVEL` | as for serve | |

## clipmux push and clipmux listen [#clipmux-push-and-clipmux-listen]

| Variable | Default | What it does |
| --- | --- | --- |
| `CLIPMUX_API_KEY` | required | The app's API key. Never in argv. |
| `CLIPMUX_PUSH_STATE_DIR` | the user's cache directory | Where unfinished pushes keep their upload tokens (0600). |
| `CLIPMUX_LISTEN_SECRET` | generated once, kept beside `agent.json` | The `whsec_` secret `listen` signs forwarded events with. |

## clipmux admin [#clipmux-admin]

`clipmux admin` reads `DATABASE_URL`, and where it needs secrets
`CLIPMUX_DATA_DIR`, `CLIPMUX_SECRETS_KEY` and `CLIPMUX_SECRETS_KEY_PREVIOUS`,
the same as serve. `clipmux admin` with no arguments lists its commands.

## The installer and Compose [#the-installer-and-compose]

These live in `/opt/clipmux/.env` (or are set when you run the installer).
Docker Compose and the installers read them; `clipmux` itself doesn't.

| Variable | Default | What it does |
| --- | --- | --- |
| `CLIPMUX_VERSION` | the release installed | The image tag Compose runs. The installer changes only this line on an upgrade. |
| `CLIPMUX_IMAGE` | `ghcr.io/visheshgubrani/clipmux` | The image, without its tag. |
| `CLIPMUX_HTTP_PORT` | `80` | The host port Caddy listens on for HTTP. |
| `CLIPMUX_HTTPS_PORT` | `443` | The host port Caddy listens on for HTTPS. |
| `CLIPMUX_ADMIN_PORT` | `8080` | The loopback port the app is published on, `127.0.0.1` only. |
| `CLIPMUX_RELEASE_URL` | the release on GitHub | Installers only: where to download the release's files from. |

## Your app's backend [#your-apps-backend]

These are not read by ClipMux: they are what an app's backend reads, as
`npx @clipmux/node init`, `clipmux admin create-integration` and the
dashboard's "Create credentials" write them. Keep them on the
server; none belongs in a browser bundle.

| Variable | What it holds |
| --- | --- |
| `CLIPMUX_URL` | The server's public URL, which the backend calls. |
| `CLIPMUX_API_KEY` | The app's `cmx_` API key, with `uploads:write`, `assets:read` and `assets:write`. |
| `CLIPMUX_SIGNING_KID` | The kid of the app's signing key, the `kid` header of every playback token. |
| `CLIPMUX_SIGNING_KEY` | The ES256 private key (PKCS #8 PEM) as one double-quoted line with `\n` escapes, which dotenv, Next.js and `node --env-file` expand. |
| `CLIPMUX_WEBHOOK_SECRET` | The `whsec_` secret webhook deliveries are signed with; only when a webhook URL was given. |
