Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

CLI Configuration

The ZERG CLI stores configuration in ~/.zerg/config.json with support for multiple profiles, environment variable overrides, and OS keyring integration for secure token storage.

Config File Location

The configuration file is stored at:

~/.zerg/config.json

The ~/.zerg/ directory is created automatically on first use. The config file is created with mode 0600 (owner read/write only).

Config Structure

{
  "api_url": "http://127.0.0.1:21434",
  "token": null,
  "default_model": null,
  "output_format": "text",
  "profiles": {
    "default": {
      "api_url": "http://127.0.0.1:21434",
      "token": "prod-api-token"
    },
    "staging": {
      "api_url": "https://staging.wildzerg.com",
      "token": "staging-token"
    },
    "local": {
      "api_url": "http://127.0.0.1:21434",
      "token": null
    }
  },
  "active_profile": "default"
}

Top-Level Fields

FieldTypeDefaultDescription
api_urlstringhttp://127.0.0.1:21434Default server URL
tokenstringnullDefault auth token
default_modelstringnullModel to use when not specified
output_formatstringtextOutput format: text or json
profilesobject{}Named configuration profiles
active_profilestringnullCurrently active profile name

Profiles

Profiles allow switching between different ZERG servers without re-entering credentials. There is no zerg config subcommand — profiles are edited directly in ~/.zerg/config.json:

{
  "profiles": {
    "production": {
      "api_url": "http://127.0.0.1:21434",
      "token": "prod-token-here"
    },
    "staging": {
      "api_url": "https://staging.wildzerg.com",
      "token": "staging-token-here"
    }
  },
  "active_profile": "production"
}

zerg --profile NAME login mints a token (against Mango auth) and stores it in that profile’s token (with its token_origin); plain zerg login stores the top-level token. Edit api_url values by hand.

Switching Profiles

--profile is a global flag — it must appear before the command:

zerg --profile staging status
zerg --profile production list

Or make a profile permanent by setting "active_profile" in ~/.zerg/config.json. When both are given, --api-url wins over --profile.

Resolution Order

The CLI resolves settings in this order (highest priority first):

  1. CLI flags (--api-url, --token, --profile)
  2. Active profile values
  3. Top-level config values
  4. Environment variables
  5. Built-in defaults

URL Resolution

api-url flag > profile.api_url > config.api_url > ZERG_API_URL > ZERG_HOST:ZERG_PORT > default

Token Resolution

token flag > profile.token > config.token > OS keyring (when a `token_keyring` marker is present) > ZERG_TOKEN

Prefer zerg login --keyring (or --bearer / ZERG_TOKEN) over the deprecated global --token form.

Environment Variables

VariableDescriptionExample
ZERG_API_URLServer base URLhttp://127.0.0.1:21434
ZERG_TOKENAuthentication tokenBearer token value
ZERG_HOSTServer hostname (with ZERG_PORT)192.168.1.100
ZERG_PORTServer port (default: 21434)21434
export ZERG_API_URL=http://127.0.0.1:21434
export ZERG_TOKEN=your-token-here
zerg status

Editing the Config File

The config is plain JSON — edit it with any editor; the CLI re-reads it on every invocation:

~/.zerg/config.json

zerg login / zerg logout are the only commands that write it (flocked read-modify-write; saves are atomic — temp file, 0600, fsync, rename). To inspect the stored token without exposing it, check the file’s token_keyring marker or use zerg keyring-get <provider> for keyring-stored API keys.

Keyring Integration

On Linux, the CLI can store tokens in the system keyring via secret-tool (libsecret) instead of the config file. This prevents tokens from being stored in plaintext.

Storing a Token in Keyring

zerg keyring-set openai

Retrieving a Token from Keyring

zerg keyring-get openai

Deleting a Token from Keyring

zerg keyring-delete openai

Testing Keyring Access

zerg keyring-test

Keyring Requirements

PlatformBackendPackage
Linuxlibsecretlibsecret-1-dev, secret-tool
macOSKeychainBuilt-in

Permission Checks

The CLI warns if the config file has overly permissive file modes:

Warning: config file ~/.zerg/config.json has loose permissions (others can read)

The config file is created with mode 0600. If permissions are modified externally, the CLI will warn on startup.