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
| Field | Type | Default | Description |
|---|---|---|---|
api_url | string | http://127.0.0.1:21434 | Default server URL |
token | string | null | Default auth token |
default_model | string | null | Model to use when not specified |
output_format | string | text | Output format: text or json |
profiles | object | {} | Named configuration profiles |
active_profile | string | null | Currently 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):
- CLI flags (
--api-url,--token,--profile) - Active profile values
- Top-level config values
- Environment variables
- 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
| Variable | Description | Example |
|---|---|---|
ZERG_API_URL | Server base URL | http://127.0.0.1:21434 |
ZERG_TOKEN | Authentication token | Bearer token value |
ZERG_HOST | Server hostname (with ZERG_PORT) | 192.168.1.100 |
ZERG_PORT | Server 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
| Platform | Backend | Package |
|---|---|---|
| Linux | libsecret | libsecret-1-dev, secret-tool |
| macOS | Keychain | Built-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.