Bring Your Own AI · Zero Shared Keys

Setting up the AI tutor

Each person connects one AI provider on their own machine — a Claude subscription, GitHub Copilot, an API key, or a free local model in Ollama / LM Studio. No key is ever stored in the repository or in kg.config.yaml.

Pick a provider

# Provider You need Cost Cites your PDFs
1 claude-code (default) Claude Pro/Max + Claude Code or Claude desktop app Your Claude plan, no API key No
2 copilot GitHub Copilot subscription + GitHub CLI Your Copilot plan Yes
3 anthropic Claude API key Pay per use Yes
4 openai (cloud) OpenAI or Google Gemini API key Pay per use (Gemini has a free tier) Yes
5 openai (local) Ollama or LM Studio + a downloaded model Free — no account, works offline Depends on model

All settings live under tutor: in kg.config.yaml. You can also override for a single run:

./kg serve --provider anthropic --model claude-sonnet-5-5   # Windows: .\kg.cmd serve --provider …
What works without AI? CLI commands (kg check, next, review, rate, search, ingest, build, judge) and the static graph (build/graph.html) work offline without any provider. kg serve requires one configured provider to start.

Step-by-step setup

1. Claude subscription (claude-code)

Default · No API key

Uses the Claude Code CLI signed in to your own Claude Pro/Max account. The app strips ANTHROPIC_API_KEY so it never bills an API key by surprise.

  1. Install Claude Code on its own or install the Claude desktop app (which bundles it).
  2. Sign in once:
    claude auth login
  3. Already the default in kg.config.yaml:
    tutor:
      provider: claude-code
      model: sonnet          # sonnet | opus | haiku, or a full model id
      # claude_path: /path/to/claude   # only if not found automatically

2. GitHub Copilot (copilot)

Book citations
  1. Install the optional Copilot SDK:
    .\setup.ps1 -WithCopilot   # macOS/Linux: ./setup.sh --with-copilot
  2. Sign in with a GitHub account that has Copilot (or set GH_TOKEN / GITHUB_TOKEN):
    gh auth login
  3. Set in kg.config.yaml:
    tutor:
      provider: copilot
      model: claude-sonnet-5.5   # any model your Copilot plan offers

3. Claude API (anthropic)

Book citations
  1. Create a key in the Anthropic Console and store it in an environment variable (never in a repo file):
    # Windows (PowerShell — then open a new terminal)
    setx ANTHROPIC_API_KEY "sk-ant-..."
    
    # macOS / Linux (add to ~/.zshrc or ~/.bashrc)
    export ANTHROPIC_API_KEY="sk-ant-..."
  2. Set in kg.config.yaml:
    tutor:
      provider: anthropic
      model: claude-sonnet-5-5
      # max_tokens: 16000        # raise if answers are cut off
      # api_key_env: MY_KEY_VAR  # if using a custom env var name

4. OpenAI or Google Gemini (openai)

Book citations

Works with any OpenAI-compatible API.

# Windows: setx OPENAI_API_KEY "..."
export OPENAI_API_KEY="..."
# OpenAI in kg.config.yaml
tutor:
  provider: openai
  model: gpt-5                           # required for this provider
  # base_url: https://api.openai.com/v1  # default
# Google Gemini in kg.config.yaml (put your Gemini key in OPENAI_API_KEY)
tutor:
  provider: openai
  model: gemini-2.5-flash
  base_url: https://generativelanguage.googleapis.com/v1beta/openai/

5. Free local model (Ollama or LM Studio)

Free · Offline · Private

No account, no API key, nothing leaves your computer. Pick an 8B+ parameter model with tool-calling support for best results.

  1. Install Ollama and pull a model:
    ollama pull llama3.1
  2. Set in kg.config.yaml (no key needed when base_url is set):
    tutor:
      provider: openai
      model: llama3.1
      base_url: http://localhost:11434/v1   # LM Studio: http://localhost:1234/v1

If long lessons get cut off in Ollama, raise num_ctx for the model.

Check that it works

.\kg.cmd serve --open   # macOS/Linux: ./kg serve --open

The terminal prints the active provider and model, and the Graph & Tutor page shows them above the chat. Click any concept and press Learn — a lesson should arrive in under a minute.

Optional kg.config.yaml settings: verify_answers: true (second AI pass checks every quiz answer key) and questions: 6.

Troubleshooting

Message What to do
couldn't find the Claude Code CLI Install Claude Code or the Claude desktop app, or set tutor.claude_path.
Claude Code isn't signed in Run the auth login command printed in the error, then retry.
needs an API key: set ANTHROPIC_API_KEY / OPENAI_API_KEY Set the env var in the terminal starting kg serve (open a new terminal after setx on Windows), or set base_url for a local server.
set tutor.model in kg.config.yaml The openai provider has no default model — specify one.
GitHub Copilot didn't start / No GitHub OAuth token Run gh auth login with a Copilot-enabled account and restart.
the model's answer was cut off Retry, raise max_tokens (Claude API) or num_ctx (Ollama), or use a larger model.
the model returned malformed output Retry; if using a small local model, switch to an 8B+ model.

Privacy