Kompass Documentation

Everything you need to run, connect, configure and debug your Kompass gateway. Source & issues: github.com/vinoth4v/kompass

What is Kompass?

Kompass is a personal LLM gateway you deploy to your own Cloudflare account (free tier). It exposes one URL that your coding tools talk to, and routes every request across free model providers by task complexity β€” so simple tasks go to fast small models, hard tasks to the best free reasoning models, and your paid Claude/OpenAI quota is only used when you choose to.

Claude Code ─(Anthropic API)──┐
Codex CLI  ─(Responses API)───                       β”Œβ–Ί FAST     lane β”‚ small & instant
Cursor     ─(OpenAI API)─────┼─►  YOUR KOMPASS  ─────┼► SIMPLE   lane β”‚ everyday edits
Cline/Roo  ─(OpenAI API)──────   (CF Worker, one     β”œβ–Ί AGENTIC  lane β”‚ tool-calling agents
Continue   ─(OpenAI API)──────    URL, one bearer,   β”œβ–Ί HARD     lane β”‚ max free reasoning
Aider      ─(OpenAI API)──────    one quota ledger)  β””β–Ί LONGCTX  lane β”‚ >60k-token contexts
kompass ui ─(local server)β”€β”€β”€β”˜
        each lane = ordered fallback chain over 10 free providers

Three properties define it:

Install

Prereqs: Node 20+, pnpm, and a free Cloudflare account. Everything else β€” Claude Code, your Cloudflare token, provider keys β€” is handled interactively by the wizard.

mkdir my-kompass && cd my-kompass
npx kompass-gateway init   # wizard installs Claude Code if needed, collects keys, deploys everything
source ~/.zshrc            # activate claude-free in the current shell

The wizard creates config/lanes.yaml, config/providers.yaml and wrangler.jsonc in that directory β€” your configuration, yours to edit. The Worker source stays inside the installed package, so npm update -g kompass-gateway upgrades the gateway without touching your settings. Prefer working from source? The clone path is fully supported:

git clone https://github.com/vinoth4v/kompass && cd kompass && pnpm install
pnpm kompass init

Every command on this page works both ways β€” write pnpm kompass <cmd> in a clone, kompass <cmd> when installed from npm.

The wizard checks for Claude Code and offers to install it (npm install -g @anthropic-ai/claude-code) if it's missing. It then prompts for your Cloudflare API token (API Tokens β†’ "Edit Cloudflare Workers" template + KV Storage:Edit scope) and your provider keys β€” no manual export needed at any point. It's idempotent, so it's safe to re-run. After it finishes, run source ~/.zshrc (or open a new terminal) so claude-free is live. Prefer copy-paste? Use the Setup Builder on the landing page β€” it generates your personalized files entirely in your browser (nothing is sent anywhere). Free keys: OpenRouter Β· NVIDIA Build Β· Google AI Studio Β· Groq Β· Mistral Β· GitHub Models (a PAT) Β· Cloudflare Workers AI Β· SambaNova Β· Cohere Β· Hugging Face. Any subset works β€” providers without keys are skipped automatically.

Throughout these docs, replace kompass.<you>.workers.dev with your deployed URL and <bearer> with the KOMPASS_BEARER you generated during setup. The bearer is the only credential any client ever needs β€” your provider API keys stay inside Cloudflare Worker secrets.

Setting up on a new / additional machine

pnpm kompass init is idempotent β€” re-running it on a second machine (or after a re-clone) detects your existing KV namespace, subdomain and secrets/.secrets.json and skips any step already done. The minimum you need is the package plus your secrets/.secrets.json (copy it from your first machine or recreate it). Then:

mkdir my-kompass && cd my-kompass
# copy secrets/.secrets.json from your original machine (it includes the CF token), then:
npx kompass-gateway init       # detects existing resources, re-deploys secrets, adds claude-free
source ~/.zshrc                # macOS/Linux: activate the new shell function
# Windows PowerShell: . $PROFILE

If you prefer the manual path, the two commands that matter on a machine that already has a deployed worker are:

pnpm exec wrangler secret bulk secrets/.secrets.json   # sync bearer to Worker
pnpm kompass config push --url https://kompass.<you>.workers.dev

Connect: Claude Code

The wizard (pnpm kompass init) detects your shell and adds the right snippet automatically. For manual setup:

macOS / Linux β€” add to ~/.zshrc or ~/.bashrc:

claude-free() {
  ANTHROPIC_BASE_URL="https://kompass.<you>.workers.dev" \
  ANTHROPIC_AUTH_TOKEN="<bearer>" \
  ANTHROPIC_MODEL="kompass-free-model-1.0" \
  claude "$@"
}

Windows PowerShell β€” add to $PROFILE:

function claude-free {
  $env:ANTHROPIC_BASE_URL = "https://kompass.<you>.workers.dev"
  $env:ANTHROPIC_AUTH_TOKEN = "<bearer>"
  $env:ANTHROPIC_MODEL = "kompass-free-model-1.0"
  claude @args
}

Then run claude-free instead of claude whenever you want free models β€” same repo, same session style, zero Pro quota used. All Claude Code features work: streaming, tool calls, images, long agentic sessions.

Connect: Codex CLI

Codex requires the OpenAI Responses API (it dropped Chat Completions support in Feb 2026) β€” Kompass speaks it natively at /v1/responses. In ~/.codex/config.toml (user-level β€” Codex ignores project-local provider config):

model = "kompass"
model_provider = "kompass"

[model_providers.kompass]
name = "Kompass"
base_url = "https://kompass.<you>.workers.dev/v1"
env_key = "KOMPASS_API_KEY"
wire_api = "responses"
export KOMPASS_API_KEY=<bearer>   # add to your shell profile
codex

Connect: Cursor

  1. Cursor Settings β†’ Models β†’ API Keys
  2. Paste your bearer token in the OpenAI API Key field
  3. Enable Override OpenAI Base URL and set it to https://kompass.<you>.workers.dev/v1
  4. Add a custom model named kompass (or kompass-hard etc.) and select it
Overriding the base URL affects Cursor's OpenAI-backed features only; Cursor-native features that require its own hosted models (e.g. Tab autocomplete) keep using Cursor's models. Chat and agent mode with the kompass model work normally.

Connect: VS Code

VS Code has no built-in AI chat or agent β€” every "AI coding in VS Code" experience comes from a free extension you install first, then point at Kompass exactly like Cursor above. Pick one:

Extension What it's like Pick it if…
Cline agentic file editor + terminal, the original of this family you want the most widely-used, battle-tested option
Roo Code a Cline fork with extra modes (Architect, Debug, Ask) you want task-specific personas without switching tools
Kilo Code another Cline fork, merges Cline + Roo Code features you want the newest feature set of the three
Continue chat/edit/autocomplete sidebar, config-file driven you want fine-grained control (separate models per role) or you also use JetBrains

All four speak the OpenAI Chat Completions API, so all four work identically well with Kompass β€” this is a taste choice, not a compatibility one.

↳ Cline / Roo Code / Kilo Code

  1. Open the Extensions panel (β‡§βŒ˜X on Mac, Ctrl+Shift+X on Windows/Linux), search "Cline" (or "Roo Code" / "Kilo Code"), click Install.
  2. Click the extension's icon in the Activity Bar (left edge), then the gear/settings icon in its panel β€” or it'll prompt you to configure a provider on first run.
  3. Set API Provider to OpenAI Compatible and fill in:
API Provider:  OpenAI Compatible
Base URL:      https://kompass.<you>.workers.dev/v1
API Key:       <bearer>
Model ID:      kompass
  1. Click Save, start a new task, and ask it something.
Verify it's working: open https://kompass.<you>.workers.dev/status.html right after β€” the "Last routes" table should show a fresh request. The extension's own UI always shows the model name you typed ("kompass"); the dashboard shows which free model actually answered.

Tool/function calling works β€” the agentic loop (file edits, running commands) runs through Kompass's AGENTIC lane models.

↳ Continue

  1. Extensions panel (β‡§βŒ˜X / Ctrl+Shift+X) β†’ search "Continue" β†’ Install.
  2. Open its config: click the gear icon in the Continue sidebar, or Command Palette (β‡§βŒ˜P / Ctrl+Shift+P) β†’ "Continue: Open config.yaml".
  3. Add a models entry:
models:
  - name: Kompass
    provider: openai
    model: kompass
    apiBase: https://kompass.<you>.workers.dev/v1
    apiKey: <bearer>
    roles: [chat, edit, apply]
  1. Save the file, reload the window if prompted, then pick Kompass from the model dropdown at the bottom of the Continue chat panel.
Verify it's working: send a chat message, then check /status.html on your Worker β€” you should see the request land with the lane the classifier picked.

Same config file (and same steps 2–4) if you use Continue in JetBrains instead of VS Code.

Connect: Aider & anything OpenAI-compatible

export OPENAI_API_BASE=https://kompass.<you>.workers.dev/v1
export OPENAI_API_KEY=<bearer>
aider --model openai/kompass

Any other client that accepts an OpenAI-compatible base URL + key works the same way: base URL …/v1, key = bearer, model kompass. Clients that validate models via GET /v1/models will find kompass and the five lane-pinned variants there.

Connect: Your own code (direct API)

Kompass is a drop-in replacement for the Anthropic (or OpenAI) API β€” point any SDK at your Worker URL and use the bearer as the API key. Auth is accepted on either Authorization: Bearer <bearer> or x-api-key: <bearer>, so both SDK auth styles work unchanged. All dialects share the same lanes, fallback chains and quota ledger.

Anthropic SDK (TypeScript):

import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  baseURL: "https://kompass.<you>.workers.dev",
  authToken: process.env.KOMPASS_BEARER,
});

const res = await client.messages.create({
  model: "kompass",              // auto routing β€” or kompass-fast/-simple/-agentic/-hard/-longctx
  max_tokens: 1024,
  messages: [{ role: "user", content: "Hello" }],
});

Anthropic SDK (Python):

from anthropic import Anthropic

client = Anthropic(
    base_url="https://kompass.<you>.workers.dev",
    auth_token=os.environ["KOMPASS_BEARER"],
)
res = client.messages.create(
    model="kompass", max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}],
)

OpenAI SDK (any language β€” note the /v1 suffix):

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://kompass.<you>.workers.dev/v1",
  apiKey: process.env.KOMPASS_BEARER,
});
const res = await client.chat.completions.create({
  model: "kompass",
  messages: [{ role: "user", content: "Hello" }],
});

Raw curl:

curl https://kompass.<you>.workers.dev/v1/messages \
  -H "x-api-key: <bearer>" \
  -H "content-type: application/json" \
  -d '{"model": "kompass", "max_tokens": 256,
       "messages": [{"role": "user", "content": "Hi"}]}'

Environment variables β€” anything that reads the Anthropic env vars (Claude Code included) redirects without code changes:

export ANTHROPIC_BASE_URL="https://kompass.<you>.workers.dev"
export ANTHROPIC_AUTH_TOKEN="<bearer>"
Kompass routes to free upstream models, not to Anthropic β€” so Anthropic-specific features (extended thinking blocks, beta headers, prompt-caching semantics) behave per whatever model serves the lane. Model names: any unrecognized name (e.g. kompass-free-model-1.0) auto-routes; kompass-<lane> pins a lane and skips the classifier. See Model names & headers.

Web workbench (kompass ui)

pnpm kompass ui starts a local claude.ai-style interface at http://127.0.0.1:4876 with four modes, all routed through your gateway:

Mode What it does
Chat Plain conversation with markdown rendering and saved sessions.
Agent Claude Code-style coding agent with bash / read / write / edit / list / search tools in a workspace directory you pick. Risky actions (bash, file writes) pause for an Allow/Deny click β€” or enable auto-approve.
Research Runs web searches (DuckDuckGo β€” no API key) and reads pages, then writes a sourced markdown report.
Slides Designs a deck and generates a real downloadable .pptx (cover, bullet slides, speaker notes), optionally researching the topic first.

Everything runs locally: tools execute on your machine, sessions persist under ~/.kompass/ui/, and the browser only talks to the local server β€” the bearer never reaches the page. The sidebar shows live per-provider daily quota.

Kompass AI β€” hosted chat app (chat/)

Prefer a gateway UI reachable from any device, not just your laptop? chat/ is a standalone Next.js app you deploy to your own Vercel account β€” login is the bearer token (entered once, validated live, stored only in that browser's localStorage). Chat (vision attachments, markdown/code rendering, served-by/lane provenance on every reply), Image generation, and Research (a real tool-use loop against two small serverless routes) β€” all routed through your Worker exactly like every other client here. Live reference deploy: kompass-chat.vercel.app (point it at your own Worker + bearer). Deploy your own:

cd chat && npm install && npm run build
vercel link && vercel deploy --prod

Requires the Worker's CORS support (ships by default) so a different origin can call /v1/messages, /v1/images/generations, etc. Agent (bash/file tools) and Slides stay kompass ui-only β€” no filesystem in a hosted serverless context.

How routing works

  1. Heuristic pre-filter (0ms): obvious signals decide instantly β€” huge context β†’ LONGCTX, tool-less short prompt β†’ FAST, etc. Roughly 60% of requests short-circuit here.
  2. Classifier verdict: otherwise a dedicated free classifier model (its own budget, separate from every coding lane) labels the task FAST / SIMPLE / AGENTIC / HARD in ~100–700ms; verdicts are cached in the Durable Object. If the classifier is down or rate-limited, routing falls back to heuristics β€” it never blocks a request.
  3. Lane chain walk: each lane is an ordered list of provider/model entries. The Durable Object pre-skips entries that are quota-exhausted or in a health cooldown, keeps sessions sticky to the model that's been serving them, and (where spread_top > 1) weighted-picks the first attempt among the top N viable candidates by recent success rate.
  4. Escalation: three consecutive failed tool-turns escalate the session one lane up. If a whole lane's chain is exhausted, Kompass cascades FAST→SIMPLE→AGENTIC→HARD before giving up — and total exhaustion returns a friendly in-chat notice, never an error.

Model names & headers

Model name Effect
kompass / kompass-free-model-1.0 (or any unrecognized name) Automatic lane routing by task complexity
kompass-fast / kompass-simple / kompass-agentic / kompass-hard / kompass-longctx Pin the request to that lane (normal fallback chain within the lane still applies)
Header Effect
x-kompass-lane: HARD Force a lane (wins over model-name pinning)
x-kompass-model: provider/model Force one exact provider/model, no fallback (testing/benchmarks)

Configuration

All routing lives in two YAML files β€” never in code. Push changes live with pnpm kompass config push (hot-reload via KV, no redeploy).

config/providers.yaml

providers:
  openrouter:
    kind: openai            # adapter dialect: openai | gemini
    base_url: https://openrouter.ai/api/v1
    key_env: OPENROUTER_API_KEY   # name of the Worker secret holding the key
    trains_on_data: true    # privacy guard keeps flagged content away from this provider
    limits: { rpm: 20, rpd: 1000 }  # your live limits β€” the shared ledger enforces these
    # optional per-model overrides:
    model_limits:
      some/model: { rpm: 5, rpd: 50 }

config/lanes.yaml

lanes:
  FAST:                                # plain list = spread_top 1 (always try first entry first)
    - google/gemini-3.5-flash-lite
    - groq/llama-3.1-8b-instant
  AGENTIC:                             # object form enables load spreading
    spread_top: 2                      # weighted-pick 1st attempt among top 2 viable entries
    chain:
      - openrouter/poolside/laguna-s-2.1:free
      - nvidia/minimaxai/minimax-m3
      - mistral/devstral-medium-latest

dispatcher:                            # the classifier (own budget, never a coding lane)
  model: google/gemini-3.1-flash-lite
  fallbacks: [groq/llama-3.1-8b-instant, mistral/mistral-small-latest]

deprecated_models:                     # rewritten to the replacement at every config push
  nvidia/old-model:
    replaced_by: nvidia/new-model
    note: "superseded"
    since: "2026-07-23"

disabled_models:                       # temporarily off, no replacement β€” reversible anytime
  - openrouter/poolside/flaky-model:free  # manage via `kompass models disable/enable`, not by hand

privacy:                               # content matching these never reaches trains_on_data providers
  block_patterns: ["**/secrets/**", "*.pem"]
  block_regexes: ["-----BEGIN [A-Z ]*PRIVATE KEY-----"]

allow_paid: false                      # paid models hard-blocked unless you flip this

Enable/disable a model without hand-editing YAML: kompass models disable <provider/model> / kompass models enable <provider/model> / kompass models list (βœ“/βœ— status for every configured entry). Edits disabled_models in place (preserving comments) and validates before writing. A disabled entry stays visible in its lane's chain β€” struck through on the status dashboard's Config tab β€” but is skipped everywhere it would otherwise be tried (chat lanes, /v1/images, /v1/embeddings, the classifier). Reversible, unlike kompass deprecate β€” no replacement, flip it back on anytime.

Design, game & creative work β€” and media generation

The lanes cover creative coding: web/UI design, CSS/WebGL animation, game code (three.js, Phaser, Godot). A 2026-07-23 tool-probe pass added models picked for exactly this traffic β€” poolside/laguna-m.1:free and nvidia/nemotron-3-super-120b-a12b:free to AGENTIC, mistralai/mistral-small-4-119b-2603 to SIMPLE. Every candidate is probed for a real tool-calling round trip before it's wired in; probe results and exclusions live in config/lanes.yaml comments and docs/DECISIONS.md.

Image generation is built in (2026-07-24): POST /v1/images/generations (OpenAI Images API-compatible) routes free Workers AI models β€” flux-1-schnell with an SDXL-lightning fallback β€” through the same quota ledger. Embeddings too: POST /v1/embeddings (bge-m3, Gemini fallback) works with Continue indexing and RAG pipelines. Chains live in config/lanes.yaml (images: / embeddings:); see API endpoints. And chat requests carrying images/PDFs now have non-Google vision fallbacks (multimodal_models in providers.yaml) β€” a Gemini quota-out no longer blocks image traffic.

Still direct-only (no gateway endpoint yet β€” free-quota-gated at ship time), on the same keys in your secrets file:

Provider (your existing key) Free media models
Google AI Studio imagen-4.0-* (images) Β· gemini-*-image (image gen + editing) Β· veo-3.1-* (video) Β· lyria-3 (music) Β· gemini-*-tts (speech)
Cloudflare Workers AI flux-2-dev / flux-2-klein / flux-1-schnell Β· SDXL variants Β· Leonardo phoenix-1.0 / lucid-origin (against your daily free neurons)

A /v1/images endpoint on the Worker is tracked as post-v1 backlog (BUILD_PLAN.md Β§8). Vision input (images/PDFs in chat requests) is already routed β€” multimodal requests skip text-only providers automatically.

Reliability model (why sessions never stall)

Free-tier providers fail constantly: mid-generation deaths, 200-responses with no content, malformed bodies, surprise 429s. Kompass's answer is buffer-then-emit: it always calls providers non-streaming, buffers the complete answer server-side, and only then writes to your editor β€” synthesizing the SSE stream your client expects from the finished response.

The visible trade-off: responses arrive as a fast burst rather than token-by-token "typing". That's deliberate β€” reliability over theater.

Quota & limits

Every provider enforces RPM (requests/minute) and RPD (requests/day) on its free tier. Kompass tracks both in a shared Durable Object ledger β€” across all your machines and all your tools β€” and pre-emptively skips exhausted providers instead of collecting 429s. Check headroom anytime:

pnpm kompass status          # CLI
https://kompass.<you>.workers.dev/status.html   # live dashboard

"Free" is a pooled, finite daily budget, not unlimited β€” but pooled across 10 providers it comfortably covers a heavy coding day. Tip: buying $10 of OpenRouter credits once (never expires) raises its :free cap from 50 to 1000 requests/day. The dashboard also shows Kompass's own Cloudflare free-tier utilization (Worker requests, CPU per request, KV, Durable Objects).

Trust & privacy

API endpoints

Endpoint Auth Purpose
POST /v1/messages bearer Anthropic Messages API (Claude Code). Streaming + tools.
POST /v1/chat/completions bearer OpenAI Chat Completions (Cursor, Cline, Continue, Aider…). Streaming + tools.
POST /v1/responses bearer OpenAI Responses API (Codex CLI). Streaming + tools.
POST /v1/images/generations bearer OpenAI Images API-compatible image generation β€” {prompt} β†’ {data: [{b64_json}]}. Free Workers AI chain (flux β†’ SDXL fallback), same quota ledger.
POST /v1/embeddings bearer OpenAI-compatible embeddings β€” {input} β†’ vectors. Workers AI bge-m3 (1024d) with Gemini fallback (3072d); response model says which served it.
GET /v1/models bearer Model roster for client pickers.
POST /v1/messages/count_tokens bearer Token estimate (chars Γ· 4) for Claude Code context tracking.
GET /status bearer JSON: lanes, per-provider quota, cooldowns, reliability, last 50 routes, CF utilization.
GET /status.html token in page Live dashboard (auto-refresh).
POST /config / GET /config bearer Hot-reload / read the compiled routing config.
GET /discovery / POST /discovery/run bearer Daily model-discovery report / trigger a fresh run.
GET /healthz none Liveness check.

CLI commands

Command Does
pnpm kompass init Guided setup wizard (idempotent).
pnpm kompass ui Local web workbench (chat / agent / research / slides).
pnpm kompass status Lanes, quota, cooldowns, reliability, routes, CF utilization.
pnpm kompass config push Compile + validate + hot-reload config/*.yaml.
pnpm kompass deploy wrangler deploy + bulk secret push.
pnpm kompass logs Live tail of the Worker.
pnpm kompass discovery [--run] Show (or refresh) the daily new-model report.
pnpm kompass deprecate <old> --replaced-by <new> Register a model deprecation; auto-substituted at every push.
pnpm kompass models disable|enable <provider/model> Reversible on/off switch β€” no replacement, unlike deprecate.
pnpm kompass models list βœ“/βœ— status for every configured model entry.
pnpm kompass bench Run the 10-task suite across lanes.
pnpm smoke -- --url <url> End-to-end smoke test against the deployed Worker.

Add --url https://kompass.<you>.workers.dev (or export KOMPASS_URL) to the status/config/discovery commands.

Troubleshooting

Symptom Cause & fix
"Free lanes are exhausted" notice in chat Every model in every lane failed for that one request (quota, cooldowns, or a very large context). Check kompass status β€” cooldowns clear in ≀10 min and quotas reset daily. Just send your next message; nothing is stuck.
claude: command not found when running claude-free Claude Code isn't installed. Run npm install -g @anthropic-ai/claude-code. The setup wizard (pnpm kompass init) now checks for this and offers to install it automatically.
claude-free: command not found The shell function is missing from your profile. Either run pnpm kompass init (it appends the function and asks if you want to add it to ~/.zshrc), or paste the snippet from the Claude Code section manually. Then source ~/.zshrc or open a new terminal.
401 "invalid bearer token" even though setup ran The KOMPASS_BEARER in your local secrets/.secrets.json drifted from the value stored in the Worker (e.g. the file was regenerated after the last deploy). Fix: pnpm exec wrangler secret bulk secrets/.secrets.json β€” this syncs all keys. If the shell function still has the old bearer, update it in ~/.zshrc to match the new value.
401 from any endpoint Wrong or missing bearer. It must be sent as Authorization: Bearer … or x-api-key: ….
503 / "no config in KV" Run pnpm kompass config push --url <your url> once after deploying or moving to a new machine. Config lives in KV and must be pushed separately from the Worker binary.
Response appears all at once, not word-by-word Expected β€” see Reliability model.
A specific model keeps failing Check its reliability on the dashboard; deprecate it (kompass deprecate) or reorder the lane chain and config push.
Dashboard shows stale/odd data after a config change Hard-refresh status.html (old cached page JS vs new JSON shape), and allow ~60s KV propagation after a push.
Cloudflare error 1102 (CPU exceeded) Extremely large requests can exceed the free plan's ~10ms CPU budget. Kompass is heavily optimized for this; if it recurs at multi-MB contexts, Workers Paid ($5/mo, 30s CPU) removes the ceiling.

MIT licensed Β· GitHub Β· Landing page Β· Built with Claude Code.