feat: Add Kilo Gateway provider#20212
Conversation
| { | ||
| env: { KILOCODE_API_KEY: "sk-..." }, | ||
| agents: { | ||
| defaults: { |
There was a problem hiding this comment.
Stale model version in config example
The code default is claude-opus-4.6 (see KILOCODE_DEFAULT_MODEL_REF in src/commands/onboard-auth.credentials.ts), but this example still references 4.5.
| defaults: { | |
| model: { primary: "kilocode/anthropic/claude-opus-4.6" } |
Prompt To Fix With AI
This is a comment left during a code review.
Path: docs/providers/kilocode.md
Line: 37
Comment:
**Stale model version in config example**
The code default is `claude-opus-4.6` (see `KILOCODE_DEFAULT_MODEL_REF` in `src/commands/onboard-auth.credentials.ts`), but this example still references `4.5`.
```suggestion
model: { primary: "kilocode/anthropic/claude-opus-4.6" }
```
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
Fixed — updated config snippet to claude-opus-4.6.
b5b35cd to
bad9eb9
Compare
bad9eb9 to
8efd2c2
Compare
|
Follow-up PR is ready from It includes:
|
|
Added commit for direct pickup: Cherry-pick: git fetch https://github.com/WantedChef/openclaw.git wantedchef/kilocode-followup-auth-fixes
git cherry-pick 0901718acPR with same commit: |
robbyczgw-cla
left a comment
There was a problem hiding this comment.
✅ Tested end-to-end on a live OpenClaw instance
Setup
• Built the PR branch from source on a clean Ubuntu VM (Node 22.22.0, pnpm 10.23.0)
• Ran openclaw onboard --non-interactive --accept-risk --kilocode-api-key
• Connected Telegram channel and routed live messages through Kilo Gateway
What I tested
• ✅ Onboarding — both --auth-choice kilocode-api-key (explicit) and auto-inference work. Config, auth profile, model defaults written correctly.
• ✅ Live routing — kilocode/anthropic/claude-opus-4.6 works
• ✅ Model switch — kilocode/openai/gpt-5.2 works
• ✅ 10 models in parallel — Claude Sonnet 4.6, Haiku 4.5, GPT-5.2, GPT-4o, Gemini 2.5 Flash, DeepSeek R1, Llama 4 Maverick, Qwen3 235B, Mistral Large, o4-mini. 10/10 responded, sub-4s latency, no rate limiting.
• ✅ SSE Streaming — works correctly
• ✅ Error handling — invalid API key → 401, invalid model → 400 with clear message
• ✅ Stress test — 5 rapid sequential requests, all succeeded
• ✅ Long output + large context — 669 token response and 2013 token input handled correctly
• ✅ Unit tests — all 22 pass (3 test files)
• ✅ models list — shows alias "Kilo Gateway"
• ✅ Pattern compliance — reviewed all 23 files against OpenRouter/Together/Venice/Moonshot patterns. Consistent throughout.
• ✅ Security — no hardcoded secrets, proper upsertAuthProfile usage
One issue to address
docs/design/kilo-gateway-integration.md has stale content from the rename:
• Line 5: references "Moltbot" instead of OpenClaw
• Lines 116, 155: MoltbotConfig type (doesn't exist in codebase — should be OpenClawConfig)
• Lines 435, 550: claims extra-params.ts was modified — not in PR's changed files
• Line 532: references docs/providers/kilo-gateway.md — actual file is docs/providers/kilocode.md
User-facing docs (docs/providers/kilocode.md, docs/concepts/model-providers.md) and all source code are clean.
Verdict
Solid, well-structured PR that follows existing patterns closely. Nice work @jrf0110 👍
───
Tested on OpenClaw 2026.2.18 (8efd2c2), Ubuntu 24.04, Node 22.22.0
Disclosure: This review was assisted by AI tools for code analysis and test execution. All findings were manually verified.
|
Design doc fixes look good, thanks John! 👍 |
9f3873a to
8320e6a
Compare
|
Thank you, @robbyczgw-cla - PR is ready to go all checks pass |
Add support for Kilo Gateway as a model provider, similar to OpenRouter. Kilo Gateway provides a unified API that routes requests to many models behind a single endpoint and API key. Changes: - Add kilocode provider option to auth-choice and onboarding flows - Add KILOCODE_API_KEY environment variable support - Add kilocode/ model prefix handling in model-auth and extra-params - Add provider documentation in docs/providers/kilocode.md - Update model-providers.md with Kilo Gateway section - Add design doc for the integration
…le model refs and CLI name in docs, fix TS2742
…ig to OpenClawConfig, remove extra-params section, fix doc path
8320e6a to
bdf5c68
Compare
|
Fixed conflicts, went through manual testing again, and looks like we're all good |
|
Landed. ✅
Thanks @jrf0110 and @markijbema. |
* feat: Add Kilo Gateway provider Add support for Kilo Gateway as a model provider, similar to OpenRouter. Kilo Gateway provides a unified API that routes requests to many models behind a single endpoint and API key. Changes: - Add kilocode provider option to auth-choice and onboarding flows - Add KILOCODE_API_KEY environment variable support - Add kilocode/ model prefix handling in model-auth and extra-params - Add provider documentation in docs/providers/kilocode.md - Update model-providers.md with Kilo Gateway section - Add design doc for the integration * kilocode: add provider tests and normalize onboard auth-choice registration * kilocode: register in resolveImplicitProviders so models appear in provider filter * kilocode: update base URL from /api/openrouter/ to /api/gateway/ * docs: fix formatting in kilocode docs * fix: address PR review — remove kilocode from cacheRetention, fix stale model refs and CLI name in docs, fix TS2742 * docs: fix stale refs in design doc — Moltbot to OpenClaw, MoltbotConfig to OpenClawConfig, remove extra-params section, fix doc path * fix: use resolveAgentModelPrimaryValue for AgentModelConfig union type --------- Co-authored-by: Mark IJbema <mark@kilocode.ai>
* feat: Add Kilo Gateway provider Add support for Kilo Gateway as a model provider, similar to OpenRouter. Kilo Gateway provides a unified API that routes requests to many models behind a single endpoint and API key. Changes: - Add kilocode provider option to auth-choice and onboarding flows - Add KILOCODE_API_KEY environment variable support - Add kilocode/ model prefix handling in model-auth and extra-params - Add provider documentation in docs/providers/kilocode.md - Update model-providers.md with Kilo Gateway section - Add design doc for the integration * kilocode: add provider tests and normalize onboard auth-choice registration * kilocode: register in resolveImplicitProviders so models appear in provider filter * kilocode: update base URL from /api/openrouter/ to /api/gateway/ * docs: fix formatting in kilocode docs * fix: address PR review — remove kilocode from cacheRetention, fix stale model refs and CLI name in docs, fix TS2742 * docs: fix stale refs in design doc — Moltbot to OpenClaw, MoltbotConfig to OpenClawConfig, remove extra-params section, fix doc path * fix: use resolveAgentModelPrimaryValue for AgentModelConfig union type --------- Co-authored-by: Mark IJbema <mark@kilocode.ai>
* feat: Add Kilo Gateway provider Add support for Kilo Gateway as a model provider, similar to OpenRouter. Kilo Gateway provides a unified API that routes requests to many models behind a single endpoint and API key. Changes: - Add kilocode provider option to auth-choice and onboarding flows - Add KILOCODE_API_KEY environment variable support - Add kilocode/ model prefix handling in model-auth and extra-params - Add provider documentation in docs/providers/kilocode.md - Update model-providers.md with Kilo Gateway section - Add design doc for the integration * kilocode: add provider tests and normalize onboard auth-choice registration * kilocode: register in resolveImplicitProviders so models appear in provider filter * kilocode: update base URL from /api/openrouter/ to /api/gateway/ * docs: fix formatting in kilocode docs * fix: address PR review — remove kilocode from cacheRetention, fix stale model refs and CLI name in docs, fix TS2742 * docs: fix stale refs in design doc — Moltbot to OpenClaw, MoltbotConfig to OpenClawConfig, remove extra-params section, fix doc path * fix: use resolveAgentModelPrimaryValue for AgentModelConfig union type --------- Co-authored-by: Mark IJbema <mark@kilocode.ai>
* feat: Add Kilo Gateway provider Add support for Kilo Gateway as a model provider, similar to OpenRouter. Kilo Gateway provides a unified API that routes requests to many models behind a single endpoint and API key. Changes: - Add kilocode provider option to auth-choice and onboarding flows - Add KILOCODE_API_KEY environment variable support - Add kilocode/ model prefix handling in model-auth and extra-params - Add provider documentation in docs/providers/kilocode.md - Update model-providers.md with Kilo Gateway section - Add design doc for the integration * kilocode: add provider tests and normalize onboard auth-choice registration * kilocode: register in resolveImplicitProviders so models appear in provider filter * kilocode: update base URL from /api/openrouter/ to /api/gateway/ * docs: fix formatting in kilocode docs * fix: address PR review — remove kilocode from cacheRetention, fix stale model refs and CLI name in docs, fix TS2742 * docs: fix stale refs in design doc — Moltbot to OpenClaw, MoltbotConfig to OpenClawConfig, remove extra-params section, fix doc path * fix: use resolveAgentModelPrimaryValue for AgentModelConfig union type --------- Co-authored-by: Mark IJbema <mark@kilocode.ai>
* feat: Add Kilo Gateway provider Add support for Kilo Gateway as a model provider, similar to OpenRouter. Kilo Gateway provides a unified API that routes requests to many models behind a single endpoint and API key. Changes: - Add kilocode provider option to auth-choice and onboarding flows - Add KILOCODE_API_KEY environment variable support - Add kilocode/ model prefix handling in model-auth and extra-params - Add provider documentation in docs/providers/kilocode.md - Update model-providers.md with Kilo Gateway section - Add design doc for the integration * kilocode: add provider tests and normalize onboard auth-choice registration * kilocode: register in resolveImplicitProviders so models appear in provider filter * kilocode: update base URL from /api/openrouter/ to /api/gateway/ * docs: fix formatting in kilocode docs * fix: address PR review — remove kilocode from cacheRetention, fix stale model refs and CLI name in docs, fix TS2742 * docs: fix stale refs in design doc — Moltbot to OpenClaw, MoltbotConfig to OpenClawConfig, remove extra-params section, fix doc path * fix: use resolveAgentModelPrimaryValue for AgentModelConfig union type --------- Co-authored-by: Mark IJbema <mark@kilocode.ai>
* feat: Add Kilo Gateway provider Add support for Kilo Gateway as a model provider, similar to OpenRouter. Kilo Gateway provides a unified API that routes requests to many models behind a single endpoint and API key. Changes: - Add kilocode provider option to auth-choice and onboarding flows - Add KILOCODE_API_KEY environment variable support - Add kilocode/ model prefix handling in model-auth and extra-params - Add provider documentation in docs/providers/kilocode.md - Update model-providers.md with Kilo Gateway section - Add design doc for the integration * kilocode: add provider tests and normalize onboard auth-choice registration * kilocode: register in resolveImplicitProviders so models appear in provider filter * kilocode: update base URL from /api/openrouter/ to /api/gateway/ * docs: fix formatting in kilocode docs * fix: address PR review — remove kilocode from cacheRetention, fix stale model refs and CLI name in docs, fix TS2742 * docs: fix stale refs in design doc — Moltbot to OpenClaw, MoltbotConfig to OpenClawConfig, remove extra-params section, fix doc path * fix: use resolveAgentModelPrimaryValue for AgentModelConfig union type --------- Co-authored-by: Mark IJbema <mark@kilocode.ai>
* feat: Add Kilo Gateway provider Add support for Kilo Gateway as a model provider, similar to OpenRouter. Kilo Gateway provides a unified API that routes requests to many models behind a single endpoint and API key. Changes: - Add kilocode provider option to auth-choice and onboarding flows - Add KILOCODE_API_KEY environment variable support - Add kilocode/ model prefix handling in model-auth and extra-params - Add provider documentation in docs/providers/kilocode.md - Update model-providers.md with Kilo Gateway section - Add design doc for the integration * kilocode: add provider tests and normalize onboard auth-choice registration * kilocode: register in resolveImplicitProviders so models appear in provider filter * kilocode: update base URL from /api/openrouter/ to /api/gateway/ * docs: fix formatting in kilocode docs * fix: address PR review — remove kilocode from cacheRetention, fix stale model refs and CLI name in docs, fix TS2742 * docs: fix stale refs in design doc — Moltbot to OpenClaw, MoltbotConfig to OpenClawConfig, remove extra-params section, fix doc path * fix: use resolveAgentModelPrimaryValue for AgentModelConfig union type --------- Co-authored-by: Mark IJbema <mark@kilocode.ai>
Summary
This is a re-attempt of #3241
kilocode) as a full provider — auth, onboarding (interactive + non-interactive), model definition, config application, cache-ttl eligibility, transcript policy, and documentation. Also added 18 unit tests and normalized the onboard CLI registration to use the standardONBOARD_PROVIDER_AUTH_FLAGSpattern (the original PR had a hardcoded--kilocode-api-keyflag outside the shared loop).Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
kilocodeprovider available during onboarding (openclaw onboard --auth-choice kilocode-api-key --kilocode-api-key <key>or justopenclaw onboard --kilocode-api-key <key>with auto-inference).KILOCODE_API_KEYenvironment variable is now recognized for auth resolution.kilocode/anthropic/claude-opus-4.6with alias "Kilo Gateway".openai-completionsAPI routed throughhttps://api.kilo.ai/api/openrouter/.Security Impact (required)
NoYes— newKILOCODE_API_KEYenv var andkilocode:defaultauth profile, following the exact same pattern as every other API-key provider.Yes— requests tohttps://api.kilo.ai/api/openrouter/when the kilocode provider is selected. No calls are made unless the user explicitly configures this provider.NoNoYes, explain risk + mitigation: The new env var and network endpoint follow identical patterns to existing providers (OpenRouter, Venice, etc.). No new attack surface beyond what any other provider integration introduces. API key is stored via the standard auth-profile mechanism.Repro + Verification
Environment
KILOCODE_API_KEY=<redacted>Steps
openclaw onboard --non-interactive --accept-risk --kilocode-api-key test-key-123kilocodeprovider pointing tohttps://api.kilo.ai/api/openrouter/pnpm test— all 7253 tests pass (834 files), including 18 new kilocode tests.Expected
Actual
Evidence
18 new tests across 2 files all pass:
src/commands/onboard-auth.config-core.kilocode.test.ts(14 tests): provider config, model definition, env var resolution, alias handling, default model selection.src/agents/pi-embedded-runner/kilocode.test.ts(4 tests): cache-ttl eligibility for kilocode with anthropic/non-anthropic models, case insensitivity.Full suite: 834 test files, 7253 passed, 1 skipped, 0 failures.
Human Verification (required)
pnpm dev --dev onboard --auth-method kilo-api-keypnpm dev --dev onboardAfter top-up
without specifying auth-method
Compatibility / Migration
YesYes— new optionalKILOCODE_API_KEYenv var andkilocodeprovider config. No existing config is affected.NoFailure Recovery (if this breaks)
Risks and Mitigations
None
Greptile Summary
This PR adds Kilo Gateway (
kilocode) as a first-class provider, following existing provider patterns for auth, onboarding (interactive + non-interactive), model definition, config application, cache-TTL eligibility, transcript policy, and documentation. The implementation is thorough, well-tested (18 new tests), and follows established patterns like OpenRouter.Key issues found:
resolveCacheRetentionlogic bug: Kilo Gateway usesopenai-completionsAPI (same as OpenRouter), but is added toresolveCacheRetention()which the docstring explicitly says only applies to Anthropic's native API. ThecacheRetentionstream option is silently ignored foropenai-completionsproviders, creating a misleading configuration surface.moltbotinstead ofopenclaw: The CLI command indocs/concepts/model-providers.mdanddocs/providers/kilocode.mdreferencesmoltbot onboardinstead ofopenclaw onboard, which is inconsistent with every other provider in the docs.claude-opus-4.5while the code correctly usesclaude-opus-4.6— the model version was apparently updated in code but not in docs.Moltbot/MoltbotConfig: The design document atdocs/design/kilo-gateway-integration.mdusesMoltbotandMoltbotConfigrather thanOpenClawandOpenClawConfig.Confidence Score: 3/5
src/agents/pi-embedded-runner/extra-params.ts(cacheRetention logic),docs/concepts/model-providers.mdanddocs/providers/kilocode.md(stale references)Last reviewed commit: b5b35cd
(2/5) Greptile learns from your feedback when you react with thumbs up/down!
Context used:
dashboard- CLAUDE.md (source)