Skip to content

feat: Add Kilo Gateway provider#20212

Merged
steipete merged 8 commits intoopenclaw:mainfrom
jrf0110:john/kilocode-provider
Feb 23, 2026
Merged

feat: Add Kilo Gateway provider#20212
steipete merged 8 commits intoopenclaw:mainfrom
jrf0110:john/kilocode-provider

Conversation

@jrf0110
Copy link
Contributor

@jrf0110 jrf0110 commented Feb 18, 2026

Summary

This is a re-attempt of #3241

  • Problem: OpenClaw has no support for Kilo Gateway as a model provider, preventing users from routing requests through the Kilo API.
  • Why it matters: Kilo Gateway provides a unified API endpoint that routes to many models behind a single API key, similar to OpenRouter. Users need this as a first-class provider option during onboarding and configuration.
  • What changed: Added Kilo Gateway (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 standard ONBOARD_PROVIDER_AUTH_FLAGS pattern (the original PR had a hardcoded --kilocode-api-key flag outside the shared loop).
  • What did NOT change (scope boundary): No changes to the gateway runtime, embedded runner streaming logic, or any other provider's behavior. No changes to the plugin SDK or extension channels.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

User-visible / Behavior Changes

  • New kilocode provider available during onboarding (openclaw onboard --auth-choice kilocode-api-key --kilocode-api-key <key> or just openclaw onboard --kilocode-api-key <key> with auto-inference).
  • KILOCODE_API_KEY environment variable is now recognized for auth resolution.
  • Default model: kilocode/anthropic/claude-opus-4.6 with alias "Kilo Gateway".
  • Provider uses openai-completions API routed through https://api.kilo.ai/api/openrouter/.

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? Yes — new KILOCODE_API_KEY env var and kilocode:default auth profile, following the exact same pattern as every other API-key provider.
  • New/changed network calls? Yes — requests to https://api.kilo.ai/api/openrouter/ when the kilocode provider is selected. No calls are made unless the user explicitly configures this provider.
  • Command/tool execution surface changed? No
  • Data access scope changed? No
  • If any Yes, 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

  • OS: macOS (darwin)
  • Runtime/container: Node 22+ / Bun
  • Model/provider: kilocode
  • Integration/channel (if any): N/A
  • Relevant config (redacted): KILOCODE_API_KEY=<redacted>

Steps

  1. openclaw onboard --non-interactive --accept-risk --kilocode-api-key test-key-123
  2. Verify config written with kilocode provider pointing to https://api.kilo.ai/api/openrouter/
  3. Run pnpm test — all 7253 tests pass (834 files), including 18 new kilocode tests.

Expected

  • Onboarding completes with kilocode as the default provider.
  • Provider config, auth profile, and model defaults are written correctly.
    Actual
  • Matches expected.

Evidence

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

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)

  • Ran pnpm dev --dev onboard --auth-method kilo-api-key
    • Was prompted to enter api key
    • Spun up tui after onboarding
    • Verified that chat messages flowed thorugh kilo's gateway
  • Ran pnpm dev --dev onboard
    • Selected Kilocode Gateway
    • Was prompted to enter api key
    • Spun up tui after onboarding
    • Verified that chat messages flowed thorugh kilo's gateway
image image

After top-up

image

without specifying auth-method

image

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? Yes — new optional KILOCODE_API_KEY env var and kilocode provider config. No existing config is affected.
  • Migration needed? No
  • If yes, exact upgrade steps: N/A

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly: Revert the branch merge. Users who haven't configured kilocode are unaffected.
  • Files/config to restore: N/A — purely additive.
  • Known bad symptoms reviewers should watch for: N/A

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:

  • resolveCacheRetention logic bug: Kilo Gateway uses openai-completions API (same as OpenRouter), but is added to resolveCacheRetention() which the docstring explicitly says only applies to Anthropic's native API. The cacheRetention stream option is silently ignored for openai-completions providers, creating a misleading configuration surface.
  • Docs use moltbot instead of openclaw: The CLI command in docs/concepts/model-providers.md and docs/providers/kilocode.md references moltbot onboard instead of openclaw onboard, which is inconsistent with every other provider in the docs.
  • Docs reference stale model version: Multiple documentation files reference claude-opus-4.5 while the code correctly uses claude-opus-4.6 — the model version was apparently updated in code but not in docs.
  • Design doc uses Moltbot/MoltbotConfig: The design document at docs/design/kilo-gateway-integration.md uses Moltbot and MoltbotConfig rather than OpenClaw and OpenClawConfig.

Confidence Score: 3/5

  • Mostly safe to merge after fixing doc inconsistencies and the cacheRetention logic concern
  • The core provider wiring (auth, onboarding, model config, env var resolution) follows established patterns closely and is well-tested. However, the cacheRetention change in extra-params.ts is inconsistent with how OpenRouter (which uses the same API) is handled, and the documentation has multiple stale references (wrong CLI binary name, wrong model version). These are fixable but should be addressed before merge.
  • Pay close attention to src/agents/pi-embedded-runner/extra-params.ts (cacheRetention logic), docs/concepts/model-providers.md and docs/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:

  • Context from dashboard - CLAUDE.md (source)

@openclaw-barnacle openclaw-barnacle bot added docs Improvements or additions to documentation cli CLI command changes commands Command implementations agents Agent runtime and tooling size: M labels Feb 18, 2026
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

24 files reviewed, 6 comments

Edit Code Review Agent Settings | Greptile

{
env: { KILOCODE_API_KEY: "sk-..." },
agents: {
defaults: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed — updated config snippet to claude-opus-4.6.

@jrf0110 jrf0110 force-pushed the john/kilocode-provider branch from b5b35cd to bad9eb9 Compare February 18, 2026 17:35
@openclaw-barnacle openclaw-barnacle bot added the channel: whatsapp-web Channel integration: whatsapp-web label Feb 18, 2026
@jrf0110 jrf0110 force-pushed the john/kilocode-provider branch from bad9eb9 to 8efd2c2 Compare February 18, 2026 17:41
@openclaw-barnacle openclaw-barnacle bot removed the channel: whatsapp-web Channel integration: whatsapp-web label Feb 18, 2026
@WantedChef
Copy link

Follow-up PR is ready from WantedChef:
#20280

It includes:

  • fix for Kilo interactive auth to ignore legacy non-API-key profiles
  • new regression tests for Kilo interactive env-key path
  • new regression tests for Kilo non-interactive explicit/inferred auth-choice paths

@WantedChef
Copy link

Added commit for direct pickup:
0901718ac (Onboard: harden kilocode API-key auth flow)

Cherry-pick:

git fetch https://github.com/WantedChef/openclaw.git wantedchef/kilocode-followup-auth-fixes
git cherry-pick 0901718ac

PR with same commit:
#20280

Copy link
Contributor

@robbyczgw-cla robbyczgw-cla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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.

@robbyczgw-cla
Copy link
Contributor

Design doc fixes look good, thanks John! 👍

@jrf0110 jrf0110 force-pushed the john/kilocode-provider branch 3 times, most recently from 9f3873a to 8320e6a Compare February 20, 2026 15:59
@jrf0110
Copy link
Contributor Author

jrf0110 commented Feb 20, 2026

Thank you, @robbyczgw-cla - PR is ready to go all checks pass

markijbema and others added 7 commits February 23, 2026 09:27
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
@jrf0110 jrf0110 force-pushed the john/kilocode-provider branch from 8320e6a to bdf5c68 Compare February 23, 2026 15:28
@jrf0110
Copy link
Contributor Author

jrf0110 commented Feb 23, 2026

Fixed conflicts, went through manual testing again, and looks like we're all good

@steipete steipete merged commit 13f32e2 into openclaw:main Feb 23, 2026
25 checks passed
@steipete
Copy link
Contributor

Landed. ✅

Thanks @jrf0110 and @markijbema.

mreedr pushed a commit to mreedr/openclaw-custom that referenced this pull request Feb 24, 2026
* 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>
plgs2005 pushed a commit to plgs2005/openclaw that referenced this pull request Feb 24, 2026
* 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>
margulans pushed a commit to margulans/Neiron-AI-assistant that referenced this pull request Feb 25, 2026
* 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>
brianleach pushed a commit to brianleach/openclaw that referenced this pull request Feb 26, 2026
* 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>
mylukin pushed a commit to mylukin/openclaw that referenced this pull request Feb 26, 2026
* 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>
r4jiv007 pushed a commit to r4jiv007/openclaw that referenced this pull request Feb 28, 2026
* 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>
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling cli CLI command changes commands Command implementations docs Improvements or additions to documentation size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants