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, API Key, or Legacy 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 Link,API Key, orLegacy API 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 Key Path
The wizard points you to:- the raw API key
Legacy API Token Path
The wizard points you to:- the raw legacy 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-key <KEY>saves a current API key for/api/v1endpoints--api-token <TOKEN>saves a legacy API token for/api/v0endpoints
- 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_KEY/KAGI_API_TOKEN/KAGI_SESSION_TOKEN- selected profile config, such as
[profiles.work.auth] - default
./.kagi.toml[auth]
--profile <NAME> to select a named profile from .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 Credentials Later
API Key for current Search API or Extract access. Choose Legacy API Token for FastGPT, public Summarizer, or Enrich.
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