Skip to main content

Quickstart Guide

This guide follows a progressive disclosure approach: you’ll start with commands that work immediately without any setup, then gradually unlock more powerful features as you configure authentication. By the end, you’ll have a fully functional kagi CLI setup tailored to your needs.

Progression Overview

Step 1: Unauthenticated Commands (30 seconds)

The fastest way to verify kagi is working is to run commands that don’t require authentication. These use Kagi’s public endpoints.

Test 1: Kagi News

Demo: News command demo Expected output:

Test 2: Small Web Feed

This fetches the latest posts from Kagi’s Small Web curation.

What These Commands Prove

  • ✅ Binary is installed and in PATH
  • ✅ Network connectivity to Kagi works
  • ✅ CLI can parse and output JSON
  • ✅ You can run kagi successfully
If these commands work, your installation is successful. If not, see the Troubleshooting guide.

Step 2: Verify Installation (1 minute)

Before moving to authenticated commands, let’s verify the installation details:
At this stage, kagi auth status will likely show:
This is expected - we’ll configure credentials next.

Step 3: Subscriber Setup with Session Token

To unlock subscriber-only features (lens search, Quick Answer, Assistant, ask-page, translate, subscriber Summarizer, and account settings management), you need a Kagi Session Token.

Getting Your Session Token

  1. Log into Kagi in your web browser
  2. Open Session Link settings
  3. Find “Session Link”
  4. Copy the full URL (looks like https://kagi.com/search?token=abc123...)
Important: This token is tied to your Kagi account and subscription. Keep it secure. Run:
Choose Session Link, paste the full Session Link or raw token, and let the wizard save and validate it. Auth Demo: Auth command demo

Option B: Environment Variable (Quick Testing)

For immediate testing without saving to disk:
Verify it works:
Expected output:

Option C: Persistent Configuration Without the Wizard

Save the token to a config file:
This creates ~/.config/kagi-cli/config.toml with your token. The CLI accepts either:
  • The full Session Link URL (recommended)
  • Just the raw token value
Verify it works:
Expected output:

Testing Subscriber Features

Now that you’re authenticated, test the subscriber commands:
Search Demo: Search command demo
Quick Answer Demo: Quick command demo Assistant Demo: Assistant command demo Ask Page Demo: Ask Page command demo Translate Demo: Translate command demo Subscriber Summarize Demo: Summarize command demo

Step 4: Paid API Setup with API Key or Legacy API Token (Optional)

If you have Kagi API access (separate from your subscription), add an API key for current /api/v1 commands or a legacy API token for older /api/v0 commands.

Getting Your API Key

  1. Log into Kagi in your web browser
  2. Open API keys
  3. Generate a new API key if you don’t have one
  4. Copy the key (looks like a long alphanumeric string)
Note: API access requires available credit. Check your Kagi account for API credit balance.

Setting Up the API Key

Option A: Auth Wizard
Choose API Key, paste it, and let the wizard add it alongside your existing Session Link. Option B: Environment Variable
Option C: Persistent Configuration
Note: If you previously set a session token, this will add the API key alongside it. Both can coexist. Use --api-token only for legacy FastGPT, Summarizer, and Enrich commands.

Testing Paid API Commands

Understanding Multi-Credential Setup

When you have multiple credentials configured:
  • Session Token: Enables lens search, session-only search options, Quick Answer, ask-page, assistant, translate, and subscriber Summarizer
  • API Key: Enables current Search API and Extract API
  • Legacy API Token: Enables FastGPT, public Summarizer, and Enrichment APIs
  • Base Search: Defaults to session unless [auth.preferred_auth] = "api"
See the Auth Matrix for the complete command-to-token mapping.

Step 5: Persistent Configuration

Now that you’ve tested everything, let’s create a robust configuration.

The config file

Kagi uses a TOML configuration file located at ~/.config/kagi-cli/config.toml. Basic configuration:
Creating the file manually:

Configuration Precedence

Kagi resolves credentials in this order (first match wins):
  1. Environment variables (KAGI_API_KEY, KAGI_API_TOKEN, KAGI_SESSION_TOKEN)
  2. Config file (~/.config/kagi-cli/config.toml)
The config file is resolved from $KAGI_CONFIG (an explicit full path), then $XDG_CONFIG_HOME/kagi-cli/config.toml, then ~/.config/kagi-cli/config.toml. This means you can override file configuration with environment variables for specific workflows or CI/CD.

Shell Profile Integration

For convenience, add environment variables to your shell profile: Bash (~/.bashrc):
Zsh (~/.zshrc):
Fish (~/.config/fish/config.fish):
PowerShell ($PROFILE):

Security Best Practices

  1. File permissions: Set ~/.config/kagi-cli/config.toml to 600 (readable only by you)
  2. Environment variables: Don’t commit these to version control
  3. Token rotation: Regenerate tokens periodically
  4. Separate contexts: Use different tokens for different environments (dev/staging/prod)

Step 6: First Real Workflows

Now let’s put it all together with practical workflows.

Workflow 1: Daily News Briefing

Make it executable and run:

Workflow 2: Research Assistant

Workflow 3: Content Pipeline

Workflow 4: Development Research

Common First Commands Reference

Here’s a quick reference of useful commands organized by category:

Information Commands

Search Commands

Content Commands

Feed Commands

What You’ve Learned

By completing this quickstart, you now understand:
  • ✅ How to verify installation works
  • ✅ The difference between session and API tokens
  • ✅ How to configure credentials (env vars and config file)
  • ✅ Basic search and content commands
  • ✅ How to combine commands in workflows
  • ✅ Where to find help and documentation

Next Steps

Continue your kagi journey:

Troubleshooting Quick Reference

For detailed troubleshooting, see the Troubleshooting guide.
Congratulations! You’re now ready to use kagi CLI effectively. Happy searching!