Skip to content

Improve error messages when no API key is configured #17

@isaacsight

Description

@isaacsight

What

When a user runs kbot for the first time without any API key configured, show a friendly, actionable setup guide instead of a raw error or stack trace.

Why

New users who install kbot via npm i -g @kernel.chat/kbot and immediately run kbot "hello" hit an authentication error. The current message points them to kbot auth but does not explain what they need (an API key from a provider) or give them options (free local models vs. cloud providers). A better first-run experience reduces friction and drop-off.

Suggested approach

  1. In the main chat entry point in cli.ts (around line 3123 where the BYOK/auth check happens), detect when no provider is configured.
  2. Instead of a one-line error, print a multi-line guide:
    No API key configured yet. Let's fix that!
    
    Quick start (pick one):
    
      Cloud (needs API key):
        kbot auth              Interactive setup — walks you through it
        kbot byok              Bring Your Own Key for 15+ providers
    
      Local (free, no key needed):
        kbot local             Use Ollama, LM Studio, or Jan
        kbot doctor            Check what's already installed
    
    Docs: https://github.com/isaacsight/kernel
    
  3. Use the existing printInfo / printWarn helpers from ui.ts for consistent styling.
  4. Exit cleanly (no stack trace).

Files to look at

  • packages/kbot/src/cli.ts — Main entry point; the auth check before starting a chat session (~line 3123)
  • packages/kbot/src/auth.tsloadConfig(), isByokEnabled(), provider detection logic
  • packages/kbot/src/ui.tsprintInfo, printWarn, printError helpers for styled output

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions