
kscli authenticates with a user-scoped API key. No admin impersonation, no JWT dance — the key is presented as a bearer token on every request and carries the permissions of the user that created it.
TL;DR
How to create an API key
API keys are created from the Knowledge Stack dashboard.1
Sign in
Open app.knowledgestack.ai. New users can sign up with email/password or Google SSO.
2
Open My Account
Click your avatar (top-right) → My Account.
3
Go to API Keys
Click the API Keys tab.
4
Create a key
Click Create API key.
5
Label it
Give the key a descriptive label (e.g.
kscli on my laptop, CI pipeline, ingest cron) so you can audit and revoke it later.6
Copy immediately
Copy the key now. Keys are shown exactly once, and
kscli needs the full sk-user-... string. If you lose it, revoke and create a new one.Revoke a key from the same page when you rotate credentials or when a laptop is lost. Revocation is immediate — the next
kscli command from that machine will exit with code 2 and prompt you to log in again.Auth flow
src/kscli/commands/auth.py, src/kscli/auth.py, src/kscli/client.py.
Commands
login
GET /users/me before writing it to disk. If validation fails, nothing is persisted.
logout
whoami
Credential storage
Override either location via environment variable:
KSCLI_CREDENTIALS_PATH— directory that holds.credentials(default/tmp/kscli). Point this at a persistent location (e.g.~/.config/kscli) if you don’t want the key wiped on reboot.KSCLI_CONFIG— full path to the config file.
Pointing at a different environment
login --url takes any base URL; it is persisted to the config file so subsequent commands don’t need it again.
- Local dev
- Staging
- Production
--base-url on the root group:
TLS / SSL
login auto-enables TLS verification when the URL is https://. For self-signed certs or corporate proxies:
kscli prints troubleshooting steps:
Exit codes
These come from
handle_client_errors() in src/kscli/client.py.
Security notes
Next steps
Quickstart
Zero to first semantic search
Configuration
Env vars, config file, precedence
