Quickstart for OpenRouter Users
OpenRouter gives you one API key across Anthropic, OpenAI, Google, DeepSeek, Qwen, Meta, Mistral, xAI, and more. Kompile treats OpenRouter as a first-class direct provider (openrouter, https://openrouter.ai/api/v1) with live catalog discovery, routed prompt caching, session affinity, structured outputs, and built-in key usage telemetry.
Fastest setup (interactive wizard — recommended)
You don't need to memorize OpenRouter's org/model IDs or CLI flags. Run the interactive wizard once to save your key, search OpenRouter's live /models catalog, and save your defaults — after that, just run kompile chat:
cd /path/to/your/repo
kompile auth login # Interactive Auth Wizard → pick OpenRouter (or `/auth` inside chat)
kompile chat # Launches SetupWizard on first run (or `kompile chat --setup` anytime)1. Authenticate
OpenRouter supports both Kompile's managed credential store and the OPENROUTER_API_KEY environment variable fallback.
Run bare kompile auth login (or /auth inside chat) for the interactive wizard, or use direct commands for scripts and multiple named keys:
# Option A: Direct masked prompt
kompile auth login openrouter
# Option B: Pipe from stdin or bind a named env var (CI / scripts)
printf '%s\n' "$OPENROUTER_API_KEY" | kompile auth login openrouter --stdin
kompile auth login openrouter --from-env OPENROUTER_API_KEY
# Option C: Ambient environment variable (no login required)
export OPENROUTER_API_KEY="sk-or-v1-..."Store multiple keys (e.g., personal vs team budget) with --name:
kompile auth login openrouter --name team --no-switch
kompile auth list2. Start chatting
Once saved via kompile chat --setup, run kompile chat. Direct CLI commands for scripts or one-off overrides:
cd /path/to/your/repo
# Interactive setup wizard — fetches live models from https://openrouter.ai/api/v1/models
kompile chat --setup
# Direct CLI overrides
kompile chat --provider openrouter --model anthropic/claude-sonnet-4-5
kompile chat --provider openrouter --model deepseek/deepseek-r1
kompile chat --provider openrouter --model google/gemini-2.5-proInside a running session, switch models at any time with /model — Kompile queries OpenRouter's live /models endpoint and caches the last-known-good catalog in ~/.kompile/cache/model-catalogs.json as an offline/outage fallback.
Non-interactive / CI turns
kompile chat --provider openrouter --model anthropic/claude-sonnet-4-5 \
--prompt "Summarize recent changes and flag risky diffs" \
--output-format stream-json3. Prompt caching, usage & cost estimation
Kompile configures OpenRouter-specific transport features automatically:
- Routed prompt caching & session affinity: Sends OpenRouter's session affinity header and retention hints (
ProviderPromptCacheCapabilities:Activation.ROUTED,SessionAffinity.OPENROUTER_SESSION_HEADER,RetentionControl.OPENROUTER). Tune with--prompt-cache-retention long|short|none(defaults tolong). - Live key telemetry (
/usage):VendorUsageServicequerieshttps://openrouter.ai/api/v1/keywith your bearer token to display live key usage and limits right inside/usage. (Account-level credit balances require a separate management key athttps://openrouter.ai/settings/credits.) - Structured outputs: Supported directly (
ProviderStructuredOutputCapabilities), which keeps Kompile's JSON tool calls and judge verdicts reliable.
4. How resolve_model works with OpenRouter
Before spawning a subagent, Kompile agents call resolve_model — a read-only lookup that never runs a model turn and never guesses credentials:
resolve_model action=providers: Listsopenrouterand its active login/env state.resolve_model action=families: Shows every model familyModelRoutingknows OpenRouter can host (claude-*,gpt-*,o1-*/o3-*/o4-*,gemini-*,gemma-*,grok-*,glm-*,qwen*,kimi-*,deepseek-*,llama-*,mistral-*,moonshot-*).resolve_model action=models provider=openrouter [query=sonnet]: Fetches OpenRouter's live/v1/modelscatalog, omits any model banned by/subagent-config, and returns copy-readytaskArgumentswithprovider=openrouterand the exact slash-qualifiedmodelID.
How your vendor of choice is resolved
- When OpenRouter is your active chat provider,
ModelRoutingkeeps every OpenRouter-hosted family onopenrouterautomatically. - When another provider is active (for example
anthropicoropenai), requesting a bare family ID routes to that family's first-party owner if configured, or refuses withAmbiguousModelRouteExceptionif multiple non-owner hosts (likeopenrouterandgithub-copilot) are configured. Passprovider=openrouterexplicitly (or copytaskArgumentsfromresolve_model) to force OpenRouter.
5. Recommended subagent configuration (/subagent-config)
WARNING
Never make top-tier models like Opus (*opus*) or Fable (*fable*) — or Astra (*astra*) / Neon (*neon*) — a subagent unless you are sure of the cost. OpenRouter makes every frontier model one model-ID away, so explicit /subagent-config bans and a dollar cap (cost-budget) are essential before launching parallel multi_task or quorum_task fan-outs.
Subagents never silently borrow the parent chat's Kompile-managed credential — pin your OpenRouter credential name (kompile auth list openrouter) in /subagent-config route:
/subagent-config ban *opus*
/subagent-config ban *fable*
/subagent-config ban *astra*
/subagent-config ban *neon*
/subagent-config route openrouter/deepseek/deepseek-v3.1 credential=default
/subagent-config role-route reviewer openrouter/anthropic/claude-sonnet-4-5 credential=default
/subagent-config per-session 4
/subagent-config cost-budget 2.00
/subagent-config preload-tools read,grep,glob,edit,write,bashPower pattern: Multi-model teams & independent judges on one key
Because OpenRouter exposes every major model family behind a single credential, it pairs naturally with Kompile's multi-model harness:
- Frontier lead + economical subagents: Run a frontier model for your main chat (e.g.,
anthropic/claude-sonnet-4-5oropenai/gpt-6.2-sol) and route bulk read/search/test workers throughopenrouterto fast, low-cost models. - Independent cross-family judge: Pair your primary coding model with a different family as The Judge so reviews aren't graded by the same model that wrote the code.
Configure multi-model teams interactively via /workflow — see Interactive Workflows.
Resuming & importing sessions onto OpenRouter
Hit a rate limit on a Claude Code, Codex, or Antigravity subscription mid-task? Import that session into Kompile and resume it seamlessly on any OpenRouter model — CrossAgentResumeCompactor automatically compacts older turns to fit your target model's context window:
# Resume Kompile Standard Chat sessions
kompile chat --continue # Resume last session in this project
kompile resume # Interactive multi-tab session browser
kompile resume-all # Restore all recently active terminal windows
# Import external CLI/IDE history and continue via OpenRouter
kompile session import --source=claude-code # Or codex, agy, opencode, cursor, ...
kompile chat --resume <id> --provider openrouter --model anthropic/claude-sonnet-4-5See Import & Resume for all 11 adapters, /resume, and subagent_resume.
Common gotchas
- Use OpenRouter's
vendor/modelIDs: OpenRouter model IDs are slash-qualified (e.g.,anthropic/claude-sonnet-4-5, not bareclaude-sonnet-4-5). Usekompile chat --setupor/modelto pick from the live catalog without guessing. - Custom gateway URLs: Point at an internal OpenRouter proxy with
--base-url https://your-proxy.example/api/v1.