Skip to content

Environment Variables

NimbleBrain reads several environment variables for authentication, server binding, and runtime behavior. This page lists every supported variable with its purpose, default, and precedence.

VariableRequiredDefaultDescription
ANTHROPIC_API_KEYYes (unless set in config)Anthropic API key for LLM calls. Can also be set via model.apiKey in nimblebrain.json.
NB_API_KEYNoAPI authentication key. When set, all HTTP endpoints (except health and login) require a valid Bearer token or session cookie. Minimum 8 characters.
NB_WORK_DIRNo~/.nimblebrainWorking directory for runtime state (conversations, logs, cache, skills). Overridden by --workdir CLI flag.
ALLOWED_ORIGINSNoComma-separated list of allowed CORS origins (e.g., https://app.example.com,https://admin.example.com). Only relevant when NB_API_KEY is set.
NB_TELEMETRY_DISABLEDNoSet to 1 to disable anonymous usage telemetry.
DO_NOT_TRACKNoStandard opt-out signal. Set to 1 to disable telemetry. Equivalent to NB_TELEMETRY_DISABLED=1.
PORTNo27247HTTP server port. Overridden by --port CLI flag.

The Anthropic API key used for all LLM calls. You can set it in the environment or in the model.apiKey field of nimblebrain.json. The environment variable is the recommended approach for production.

Terminal window
export ANTHROPIC_API_KEY=sk-ant-api03-...

If both the environment variable and the config field are set, the config field takes precedence.

When set, NimbleBrain requires authentication on all API endpoints except /v1/health, /v1/bundles/health, and POST /v1/auth/login.

Terminal window
export NB_API_KEY=your-secret-key-here

Requirements:

  • Minimum 8 characters. The server throws an error at startup if the key is shorter.
  • Keys shorter than 16 characters produce a warning recommending a longer key for production use.

Authentication uses constant-time comparison to prevent timing attacks. Clients authenticate with either:

  • A Bearer token in the Authorization header
  • An nb_session HttpOnly cookie set by POST /v1/auth/login

When NB_API_KEY is not set, the server runs in dev mode with no authentication and Access-Control-Allow-Origin: *.

Sets the working directory where NimbleBrain stores all runtime state.

Terminal window
export NB_WORK_DIR=/data/nimblebrain

The working directory contains:

  • nimblebrain.json — Config file (if no --config flag is set)
  • conversations/ — JSONL conversation files (when using JSONL store)
  • logs/ — Structured JSONL logs
  • skills/ — Global skill files
  • cache/ — Bundle cache

Precedence: --workdir flag > NB_WORK_DIR env var > workDir in config file > command default (~/.nimblebrain for nb serve, ./.nimblebrain for nb dev)

Controls which origins can make cross-origin requests when NB_API_KEY is set.

Terminal window
export ALLOWED_ORIGINS=https://app.example.com,https://admin.example.com

Behavior depends on the combination of NB_API_KEY and ALLOWED_ORIGINS:

NB_API_KEYALLOWED_ORIGINSCORS behavior
Not setAccess-Control-Allow-Origin: * (dev mode)
SetNot setSame-origin only (no CORS header sent)
SetSetOnly listed origins get Access-Control-Allow-Origin with Access-Control-Allow-Credentials: true

Separate multiple origins with commas. Whitespace around origins is trimmed.

Two environment variables disable anonymous telemetry. Either one is sufficient.

Terminal window
# Either of these disables telemetry
export NB_TELEMETRY_DISABLED=1
export DO_NOT_TRACK=1

DO_NOT_TRACK follows the Console Do Not Track standard. You can also disable telemetry via:

  • telemetry.enabled: false in nimblebrain.json
  • nb telemetry off CLI command

When the same setting can be configured in multiple places, this is the resolution order (highest priority first):

SettingCLI flagEnv varConfig fileDefault
Working directory--workdirNB_WORK_DIRworkDir~/.nimblebrain
Model--modeldefaultModelclaude-sonnet-4-5-20250929
Port--portPORThttp.port27247
API keyNB_API_KEYNone (no auth)
Anthropic keyANTHROPIC_API_KEYmodel.apiKey
Telemetrynb telemetry offNB_TELEMETRY_DISABLED / DO_NOT_TRACKtelemetry.enabledEnabled

A typical production setup with all relevant variables:

Terminal window
export ANTHROPIC_API_KEY=sk-ant-api03-...
export NB_API_KEY=$(openssl rand -hex 32)
export NB_WORK_DIR=/data/nimblebrain
export ALLOWED_ORIGINS=https://app.example.com
export NB_TELEMETRY_DISABLED=1