Skip to content

Configuration

Latentry reads .env.local in its folder (the install script copies it from .env.example). The Settings page can set backends, gallery folders, the tagger and profile defaults too; what it saves (latentry.settings.json) takes precedence, and anything it leaves alone falls back to .env.local. Restart Latentry after editing .env.local.

Variable Default What it does
GEN_BACKENDS — Backends: id\|kind\|url\|profile, separated by ;
GEN_TOKEN_<ID> — A backend's token, by its id in upper case
GEN_MODEL_<ID> first listed A comfyui backend's checkpoint, as ComfyUI lists it
GEN_CONTROLNET_<ID> — A comfyui backend's Pose ControlNet, as ComfyUI lists it; unset: no pose
GALLERY_SAVE_DIR ./output Where finished pictures are saved; unset: not saved
GALLERY_DIRS — Other folders to browse read-only, separated by ;
GALLERY_AUTO_TAG off 1: tag each saved picture with WD14 as it arrives
WD14_MODEL_DIR — Folder of the built-in WD14 tagger (model.onnx, selected_tags.csv)
WD14_THRESHOLD, WD14_CHARACTER_THRESHOLD 0.35, 0.85 How sure a tag must be
TAGGER_BACKEND automatic builtin, or a backend id
A1111_TAGGER_MODEL first "wd" model The A1111 tagger extension's model
LATENTRY_HOST 127.0.0.1 0.0.0.0 to use Latentry from other devices
SETTINGS_EDIT local Who may change settings: local, lan or off
LATENTRY_SETTINGS_FILE ./latentry.settings.json Where the Settings page saves. Model info (latentry.models.json) goes in the same folder
LATENTRY_ALLOW_UNC off 1: let the Settings page use network folders (\\server\share)
ALLOWED_HOSTS — Extra hostnames /api answers for (behind a reverse proxy)
REQUEST_BUDGET_* see below Per-device request limits; REQUEST_BUDGET=off turns them off
LATENTRY_ENGINE on off: do not start the built-in engine with Latentry
LATENTRY_RUNTIME_DIR ./.runtime Where the engine (uv, Python, PyTorch) is installed
HF_TOKEN — Only for models that need a Hugging Face login
PORT 3000 The install scripts' port

The engine also reads LATENTRY_DEVICE, LATENTRY_DTYPE, LATENTRY_OFFLOAD, LATENTRY_MAX_BATCH and LATENTRY_VRAM_FRACTION to override its GPU plan (see Setup and the engine), and LATENTRY_LORA_KEEP: how many LoRAs stay in the loaded model between runs, switched off, so calling one again is quick (default 4; 0 takes each out after its run).

The variables on this page, and the ones in .env.example and the guide, keep their names and meaning between releases; see Compatibility.

.env.example

Every variable, with its explanation:

# Copy to .env.local and fill in. Everything here is read by the server only;
# nothing reaches the browser except the backend ids.
#
# The Settings page (/settings) can set backends, gallery folders and profile
# defaults too. What it saves (latentry.settings.json) takes precedence; what
# it leaves alone falls back to the values below.

# ── Backends ────────────────────────────────────────────────────────────────
# One entry per backend, separated by ";":   id|kind|url|profile
#   id       what the UI calls it (a-z, 0-9, "-", "_")
#   kind     diffusers  a server speaking the API in docs/backend-api.md
#            a1111      AUTOMATIC1111 or Forge, started with --api
#            comfyui    a ComfyUI server (txt2img; it draws with the first
#                       checkpoint it lists, another is chosen on Settings)
#   url      where it listens
#   profile  generic | sdxl | illustrious | pony | anima  (the form's starting
#            point; it can be changed in the UI at any time)
GEN_BACKENDS=anima|diffusers|http://localhost:7865|anima;sdxl|a1111|http://localhost:7860|illustrious

# Tokens, by backend id in upper case (non-alphanumerics become "_").
#   diffusers: sent as "Authorization: Bearer <token>"
#   a1111:     "user:password", as given to --api-auth
#   comfyui:   ComfyUI has no login; a token is sent as a Bearer token, for a
#              proxy in front of it
# A token is only sent to the address GEN_BACKENDS gives its id; a backend
# moved elsewhere on the Settings page needs its token typed there.
# GEN_TOKEN_ANIMA=
# GEN_TOKEN_SDXL=user:password

# A comfyui backend's checkpoint, by backend id in upper case, as ComfyUI lists
# it (folders included). Unset: the first checkpoint ComfyUI lists.
# GEN_MODEL_COMFY=sdxl\base.safetensors

# ── WD14 tagging ────────────────────────────────────────────────────────────
# Latentry can run a WD14 tagger itself, on the CPU, with no backend involved.
# Download model.onnx and selected_tags.csv from a SmilingWolf WD tagger on
# Hugging Face (Apache-2.0), e.g. wd-eva02-large-tagger-v3 (best, ~1.2 GB) or
# wd-vit-tagger-v3 (smaller), into a folder of their own:
# WD14_MODEL_DIR=D:\models\wd-eva02-large-tagger-v3
# WD14_THRESHOLD=0.35
# WD14_CHARACTER_THRESHOLD=0.85
#
# What tags pictures: "builtin", a backend id, or unset for the built-in model
# when WD14_MODEL_DIR is set, else the first backend with a tagger.
# TAGGER_BACKEND=builtin
# A1111 / Forge with the WD14 tagger extension: which of its models to use.
# Default: the first one whose name contains "wd".
# A1111_TAGGER_MODEL=wd-v1-4-moat-tagger.v2

# Older single-backend form, still read when GEN_BACKENDS is unset:
# DIFFUSION_SERVER_URL=http://localhost:7865
# DIFFUSION_API_TOKEN=

# ── Gallery ─────────────────────────────────────────────────────────────────
# Where Latentry saves every finished image, with its settings embedded.
# Leave unset to not save (images can still be downloaded one by one).
GALLERY_SAVE_DIR=./output
# Other folders to browse, read-only, separated by ";" (e.g. ComfyUI's or the
# web UI's output folder). These must be on the machine running Latentry.
# GALLERY_DIRS=D:\ComfyUI\output;D:\stable-diffusion-webui\outputs\txt2img-images
# Tag each saved image with WD14 as it arrives (uses the tagger once per image).
# GALLERY_AUTO_TAG=1

# ── Settings page ───────────────────────────────────────────────────────────
# Who may change settings from the browser:
#   local (default)  only on this computer (http://localhost)
#   lan              from any address /api answers
#   off              nobody; edit this file or the settings file by hand
# SETTINGS_EDIT=local
# Where the settings page saves (it holds backend tokens; keep it private).
# LATENTRY_SETTINGS_FILE=./latentry.settings.json
# Network folders (\\server\share) on the settings page. Off: Windows signs in
# to a network folder's server as you when Latentry checks it, so whoever may
# change settings could choose where that sign-in goes. Folders set in this
# file are not affected.
# LATENTRY_ALLOW_UNC=1

# ── Access ──────────────────────────────────────────────────────────────────
# Latentry listens on this computer only (127.0.0.1). To use it from a phone
# or another computer on your network, listen on every interface, then open
# http://<this computer's address>:3000 there. On Windows, allow Node.js
# through the firewall on private networks when asked.
# LATENTRY_HOST=0.0.0.0
#
# Other devices must be paired before they can use it: Settings > Phones and
# other computers > Add a device shows a code to type on them (one use, 10
# minutes); a device stays paired for 30 days. Only turn pairing off behind a
# reverse proxy on this computer that does its own login.
# LATENTRY_PAIRING=off
#
# The key paired devices are recognised by, as 64 hex characters, instead of
# the file latentry.pairing-key. Set it at launch from your keychain (see the
# guide's "keep the pairing key in your keychain"); do not write it here.
# LATENTRY_PAIRING_KEY=
#
# /api answers only for localhost and private-network addresses. To serve it
# under a hostname (e.g. behind a reverse proxy), list the hostname here.
# ALLOWED_HOSTS=studio.home.arpa

# Per-IP request budget (per minute). REQUEST_BUDGET=off turns it off.
# REQUEST_BUDGET_PAGE_PER_MIN=120
# REQUEST_BUDGET_API_PER_MIN=300
# REQUEST_BUDGET_POST_PER_MIN=30
# REQUEST_BUDGET_GLOBAL_PER_MIN=1200
# REQUEST_BUDGET_SSE_PER_IP=12

# ── Latentry's own engine (see engine/README.md; set up from the Setup page) ──
# LATENTRY_ENGINE=off               # do not start the engine with Latentry
# LATENTRY_RUNTIME_DIR=./.runtime   # where uv, Python and PyTorch are installed
# LATENTRY_ENGINE_PACKAGES=latest   # install the newest Python packages, not the pinned ones
#                                   # (not hash-checked; for when a pinned one has a known
#                                   # vulnerability and no Latentry update has come yet)
# HF_TOKEN=hf_...                   # only for models that need a Hugging Face login