@sachitv/opencode-kilo-code-provider
v1.1.1
Published
OpenCode provider plugin for the Kilo Code Gateway with dynamic model discovery.
Maintainers
Readme
@sachitv/opencode-kilo-code-provider
An OpenCode provider plugin for the Kilo Code Gateway.
This package is a separate OpenCode provider (not the built-in kilo provider). It dynamically fetches the model list from Kilo's OpenAI-compatible /models endpoint at startup and refreshes it when the active account changes in OpenCode 2, so you never have to hand-maintain model entries in your config.
The API key stays in OpenCode's credential store. The organization id is non-secret config sent as:
X-KiloCode-OrganizationId: your_org_idThe organization id is a UUID (e.g. xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) found in your Kilo dashboard URL.
Install
From npm
bun add @sachitv/opencode-kilo-code-providerThen add it to your OpenCode 2 config:
{
"$schema": "https://opencode.ai/config.json",
"plugins": [
{
"package": "@sachitv/opencode-kilo-code-provider",
"options": {
"organizationId": "your_org_id",
"defaultModel": "kilo-auto/free"
}
}
]
}OpenCode 1 uses the singular plugin key and tuple form:
{
"$schema": "https://opencode.ai/config.json",
"plugin": [
["@sachitv/opencode-kilo-code-provider", { "organizationId": "your_org_id", "defaultModel": "kilo-auto/free" }]
]
}From source (local development)
git clone https://github.com/sachitv/opencode-kilo-code-provider.git
cd opencode-kilo-code-provider
bun install
bun run buildFor OpenCode 2 local development, expose the package through the discovered plugin directory. From the project where OpenCode runs, link the provider package root after building it:
mkdir -p .opencode/plugins
ln -s /absolute/path/to/opencode-kilo-code-provider .opencode/plugins/kilo-codeOpenCode 1 local development uses the plugin key with file:///absolute/path/to/opencode-kilo-code-provider/dist/index.js.
Add the API Key
Run OpenCode and connect the custom provider id:
/connectChoose kilo-code and paste your Kilo Gateway API key. OpenCode stores it in its credential store. In OpenCode 1 this is
~/.local/share/opencode/auth.json; OpenCode 2 manages the connection through its integration API. Do not put the key
in opencode.json.
OpenCode 2 refreshes the authenticated model list automatically after /connect or switching accounts.
In OpenCode 1, restart once after /connect to refresh organization-scoped catalogs.
The configured defaultModel remains usable immediately after connecting.
Use Models
Restart OpenCode after installing the plugin, then run:
/modelsModels returned by Kilo's /models endpoint appear under Kilo Code Gateway. Use them as kilo-code/<model-id>:
{
"model": "kilo-code/kilo-auto/free"
}How It Works
The package supports both OpenCode 1 and OpenCode 2 from the same entrypoint. OpenCode 1 calls the legacy server
export; OpenCode 2 calls the default export's setup function.
The package has two parts:
dist/provider.jsexportscreateKiloCode, an AI SDK provider factory wrapping Kilo's OpenAI-compatible gateway athttps://api.kilo.ai/api/gateway.dist/index.jsexports both plugin APIs. It registers auth, fetches models fromGET /models, and points each discovered model atcreateKiloCode.
The provider reads credentials from OpenCode at request time. No keys are stored in config files.
Configuration Options
| Option | Required | Description |
|--------|----------|-------------|
| organizationId | No | Kilo organization id sent as X-KiloCode-OrganizationId. Required for org-scoped requests. |
| defaultModel | No | Sets the model if none is already configured. Defaults to kilo-auto/free. |
| providerID | No | Override the provider id (default: kilo-code). |
| baseURL | No | Override the Kilo gateway base URL (default: https://api.kilo.ai/api/gateway). |
Development
This project uses Bun only. No npm.
bun install # install deps
bun run check # typecheck + test + build
bun test # run tests
bun run build # build dist/
bun run typecheck # typecheck onlyLicense
MIT
