kscli resolves configuration from multiple sources in strict precedence order:
CLI flags > environment variables > config file > defaults
This is implemented per-setting in src/kscli/config.py — each getter function checks sources in order.
| Variable | Description | Default |
|---|---|---|
KSCLI_BASE_URL |
API base URL | http://localhost:8000 |
ADMIN_API_KEY |
Admin API key for assume-user authentication |
(required) |
KSCLI_FORMAT |
Default output format (table, json, yaml, id-only, tree) |
table |
KSCLI_VERIFY_SSL |
Enable SSL certificate verification (true/false) |
true |
KSCLI_CA_BUNDLE |
Path to custom CA certificate bundle | (system default via certifi) |
KSCLI_CONFIG |
Path to config file | ~/.config/kscli/config.json |
KSCLI_CREDENTIALS_PATH |
Path to credentials cache file | /tmp/kscli/.credentials |
Default location: ~/.config/kscli/config.json (override with KSCLI_CONFIG).
Created automatically on first run (src/kscli/config.py:86-92). Example:
{
"environment": "prod",
"base_url": "https://api.knowledgestack.ai",
"verify_ssl": true,
"admin_api_key": "your-admin-key",
"format": "json",
"ca_bundle": "/path/to/ca-bundle.crt"
}All fields are optional. Missing fields fall through to environment variables or defaults.
These flags can appear anywhere in the command (not just before the subcommand), thanks to GlobalOptionsGroup (src/kscli/cli.py:41-95):
| Flag | Description |
|---|---|
--format / -f |
Output format for this command |
--no-header |
Suppress table headers |
--base-url |
Override API base URL for this command |
# These are equivalent:
kscli --format json folders list
kscli folders list --format json
kscli folders --format json listThe settings environment command sets multiple config values at once (src/kscli/commands/settings.py:17-33):
kscli settings environment local # http://localhost:8000, verify_ssl=false
kscli settings environment prod # https://api.knowledgestack.ai, verify_ssl=trueYou can override the base URL for a preset:
kscli settings environment prod --base-url https://custom.example.comPresets write to the config file. The specific values (src/kscli/commands/settings.py:17-28):
| Preset | base_url |
verify_ssl |
|---|---|---|
local |
http://localhost:8000 |
false |
prod |
https://api.knowledgestack.ai |
true |
kscli settings showDisplays the fully resolved configuration — the merged result of all sources (src/kscli/commands/settings.py:60-82):
┌──────────────┬──────────────────────────────────────────────┐
│ Key │ Value │
├──────────────┼──────────────────────────────────────────────┤
│ config_file │ /Users/you/.config/kscli/config.json │
│ base_url │ https://api.knowledgestack.ai │
│ verify_ssl │ True │
│ ca_bundle │ (default) │
│ format │ table │
│ environment │ prod │
│ admin_api_key│ (set) │
└──────────────┴──────────────────────────────────────────────┘
--base-urlCLI flag (stored in Click context)KSCLI_BASE_URLenvironment variablebase_urlfield in config file- Default:
http://localhost:8000
ADMIN_API_KEYenvironment variableadmin_api_keyfield in config file- Error if neither is set
--format/-fCLI flagKSCLI_FORMATenvironment variableformatfield in config file- Default:
table
verify_ssl:
KSCLI_VERIFY_SSLenvironment variable (true/1/yes)verify_sslfield in config file- Default:
true
ca_bundle:
KSCLI_CA_BUNDLEenvironment variableca_bundlefield in config file- Default: system certificates via
certifi