Documentation Index
Fetch the complete documentation index at: https://kagi.micr.dev/llms.txt
Use this file to discover all available pages before exploring further.
kagi auth
kagi auth is the main onboarding path for this CLI. On a real terminal, it launches an interactive setup wizard that lets you choose Session Link or API Token, shows the official Kagi settings page for that credential, accepts a paste, saves into ./.kagi.toml, and validates the selected credential immediately.
Synopsis
Interactive Wizard
Run this on a TTY:- shows your current auth state and config path
- lets you choose
Session LinkorAPI Token - shows the official place to get that credential
- accepts the pasted value
- asks before overwriting an existing config value of the same type
- validates the selected credential
- saves to
./.kagi.toml - warns if an environment variable will still override what you saved
Session Link Path
The wizard points you to:- the full Session Link URL
- the raw token value
API Token Path
The wizard points you to:- the raw API token
Non-TTY Behavior
Barekagi auth is intentionally interactive. In non-interactive environments it fails fast instead of hanging:
Subcommands
| Subcommand | Purpose |
|---|---|
status | Show which credentials are configured and where they come from |
check | Validate the currently selected primary credential |
set | Save credentials non-interactively |
kagi auth status
kagi auth check
kagi auth set
Use this when you want scripting or explicit non-interactive config writes.
--session-token <TOKEN_OR_URL>saves a Session Link or raw session token--api-token <TOKEN>saves a raw API token
- creates
./.kagi.tomlwhen needed - preserves the other credential if you only set one
- normalizes full Session Link URLs into the raw token value
- writes the config file with restrictive permissions on Unix
Precedence Rules
The CLI resolves credentials in this order:KAGI_API_TOKEN/KAGI_SESSION_TOKEN./.kagi.toml
Preferred Auth
When both auth methods exist, basekagi search follows [auth.preferred_auth]:
"session"- default"api"
Common Flows
Fastest Subscriber Setup
Non-Interactive Session Setup
Add API Token Later
API Token, paste it, then verify:
Security Notes
auth statusandauth checknever print the secret values./.kagi.tomlis local plaintext config, so keep it out of version control- on Unix, the CLI writes restrictive file permissions when saving the config
- environment variables still override config and may be preferable in CI/CD