Environment variables
Single-page reference for every environment variable @pleach/core reads — runtime flags, storage adapters, provider credentials, and observability.
The runtime reads a small, named set of environment variables. Anything not listed here is either an application-level concern or a sibling package's contract.
Runtime flags
The quickstart factories (createPleachRoute, createPleachRoutes,
createPleachAgent) and their default provider stream read the
PLEACH_* variables below. Each one has a default, so an unset
variable changes nothing. A SessionRuntime you construct yourself
takes these choices as config instead.
| Variable | Default | Effect |
|---|---|---|
PLEACH_TRACE | off | 1 or true prints the runtime's debug breadcrumbs. Warnings and errors print either way. |
PLEACH_PROBES | off | 1 or true prints the diagnostic probe lines to stdout. |
PLEACH_PROMPT_DUMP | off | 1 prints each provider request as sent. It includes prompt text, so keep it out of production. |
PLEACH_REASONING_EFFORT_UTILITY, _SYNTHESIZE, _REASONING, _CONVERSE, _PLANNER | medium (planner: high) | medium, high or off for that call class. The route's reasoningEffortByCallClass wins over its variable. |
PLEACH_REASONING_CAP | unset | Deprecated. false turns reasoning effort off for every class that has no setting of its own. |
PLEACH_MAX_OUTPUT_TOKENS | 8192 | Output-token ceiling the default provider stream asks for. |
PLEACH_MODEL_CATALOG | on | false skips the model-catalog fetch, so every call row is unpriced. |
PLEACH_PROVIDER_CATALOG | on | false turns off rerouting to another upstream in the same model family. |
PLEACH_STRIP_TOOLS_ON_SYNTHESIZE | on | false keeps the tool list on the final answer call. |
PLEACH_QUALITY_BACKSTOPS | on | false turns off the fallbacks that compose an answer from completed tool results. |
No `FEATURE_*` flags
@pleach/core reads no FEATURE_* variables, and an audit in the
package source refuses them. A feature flag your own app reads has no
effect on a @pleach/core install. To drive a turn with no provider
account, use the headless driver in @pleach/core/testing.
Provider credentials
These map to the native transport for the corresponding family. The
openrouter transport only needs OPENROUTER_API_KEY regardless of
which family is locked.
| Env var | Required for |
|---|---|
ANTHROPIC_API_KEY | native Anthropic transport. |
OPENAI_API_KEY | native OpenAI transport. |
GOOGLE_GENERATIVE_AI_API_KEY | native Google transport. Primary; GOOGLE_API_KEY is accepted as a legacy fallback. |
DEEPSEEK_API_KEY | native DeepSeek transport. |
MISTRAL_API_KEY | Nothing yet. Mistral has no native stream, and nothing reroutes it: with only this key the route answers 503 no_provider_key. Set OPENROUTER_API_KEY or pass a providerStream. |
OPENROUTER_API_KEY | The openrouter transport for any family. |
Storage credentials
@pleach/core reads no SUPABASE_* variable. SupabaseAdapter and
SupabaseSaver take a Supabase client you build, so the variable
names are your app's choice. Build the browser adapter's client with
the anon key, so row-level security applies, and keep the service-role
key on the server.
The Memory and IndexedDB adapters don't read any env vars either.
They exist for tests and for browser-only sessions where the page owns
storage.
Local sidecar
The local sidecar that pleach tui starts reads these settings. They
have no effect on a server you mount yourself.
| Env var | Effect |
|---|---|
PLEACH_TENANT_ID | The tenant the sidecar runs as. Default default. Its SQLite store (pleach.db in the config dir) scopes sessions, checkpoints and event-log reads to this tenant, every audit row carries it, and /sidecar/replay replays only this tenant's events. |
PLEACH_CONFIG_DIR | The config dir that holds pleach.db. Default $XDG_CONFIG_HOME/pleach when XDG_CONFIG_HOME is set, else ~/.pleach. |
PLEACH_TURN_DEADLINE_MS | Host deadline for one turn segment on the createPleachRoutes execute route. Default 600000 (10 minutes); 0 disables it. On expiry the runtime emits turn.parked { token } and the TUI continues automatically through POST /sessions/:id/turns/:token/continue, so this bounds a response, not the task. |
Setting `PLEACH_TENANT_ID` on an existing config dir
Rows already in pleach.db were written under default. Once you set
another tenant, those sessions, checkpoints and events no longer show
up: --continue and --resume don't find them. Unset the variable, or
set it back to default, to see them again.
Provider key resolution order
On the quickstart routes, the runtime looks for a provider in this order and stops at the first hit:
- A provider or
providerStreamyou pinned in the route config. - The session's BYOK key, if the session was started with one.
- The matching process env var from the table above.
With none, the route still mounts, and each request gets a 503 with
code no_provider_detected or no_provider_key.
Retired flags
Two older variables are retired, and setting either has no effect:
- A pre-1.0 dual-write flag. The runtime now writes the canonical event log shape unconditionally.
- A host-side mock-mode flag. It gated a mock tool executor
that synthesized tool results. It never mocked the provider, and the
runtime constructors never read it. For a turn driven without a
provider account, use
@pleach/core/testing.