# Kilo Code

> Wire Kilo Code across CLI, VS Code, and JetBrains to HeyEly via one global config file.

Kilo Code shares a single configuration file across its CLI, VS Code extension, and JetBrains plugin. Define HeyEly once as a custom OpenAI-compatible provider targeting Chat Completions at `https://heyely.si/v1`.

## Set up

1. Generate an API key in [Developers](https://heyely.si/keys) and export it as `HEYELY_API_KEY`.
2. Add the HeyEly provider block to your global config at `~/.config/kilo/kilo.jsonc` (on Windows, `C:\Users\<you>\.config\kilo\kilo.jsonc`).

```jsonc
{
  "$schema": "https://app.kilo.ai/config.json",
  "model": "heyely/claude-sonnet-5.5",
  "provider": {
    "heyely": {
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "https://heyely.si/v1",
        "apiKey": "{env:HEYELY_API_KEY}"
      },
      "models": {
        "claude-sonnet-5.5": {
          "id": "anthropic/claude-sonnet-5.5",
          "name": "Claude Sonnet 5.5",
          "tool_call": true,
          "limit": { "context": 1000000, "output": 32000 }
        }
      }
    }
  }
}
```

3. Restart Kilo Code to load the changes.

Note that `{env:HEYELY_API_KEY}` only resolves inside your global config; Kilo ignores env interpolation inside repository-level configs. Always keep keys out of project files.

Each property name inside `models` is the short local alias Kilo displays and accepts in `model` and `-m` (keep it slash-free), whereas `id` is the exact HeyEly catalog ID sent over the wire.

Prefer configuring inside VS Code? Open Settings, select **Providers**, scroll down to **Custom provider**, pick **OpenAI Compatible** under **Provider API**, and enter the base URL and key. Explicit token limits and tool-calling flags still need to live in the config file.

## Verify

1. Run `kilo models heyely` and confirm your configured model appears.
2. Run `kilo roll-call "^heyely/"` to send a lightweight probe and display model latency.
3. Run `kilo run -m heyely/claude-sonnet-5.5 "Reply with exactly: gateway-ok"`.
4. Open [Credit and usage](https://heyely.si/usage) to see the test call at the top of **Spend** under your chosen model.

## Pick a model

* Kilo relies on `limit.context` to trigger automatic compaction; without it, conversations never compact. Always define both `context` and `output`.
* `limit.output` maps directly to `max_tokens`, defaulting to a 32,000 cap in Kilo.
* Setting `tool_call: true` unlocks file editing and terminal tool execution.
* Need a model served through `POST /v1/responses`? Switch `npm` to `@ai-sdk/openai` while keeping the same `baseURL`.

## Troubleshooting

| You see                        | Cause                                                                     | Fix                                                                                              |
| ------------------------------ | ------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
| `401 invalid_api_key`          | `{env:HEYELY_API_KEY}` was put in a project config or not exported        | Move the provider into your global config and export `HEYELY_API_KEY`                            |
| Model missing from list        | Invalid JSONC syntax or `model` alias mismatch                            | Check syntax and ensure `model` uses `heyely/` plus your `models` key                            |
| Agent cannot modify files      | `tool_call` is disabled                                                   | Add `"tool_call": true`                                                                          |
| Context never compacts         | `limit.context` omitted                                                   | Define `limit.context` on the model                                                              |
| `404 model_not_found`          | `id` does not match HeyEly's catalog                                      | Copy the exact ID from the Models page                                                           |
| `402 insufficient_credit`      | No credit available on the account                                        | [Add credit](https://heyely.si/credit?step=add)                                                                   |
| `402 free_credit_not_eligible` | Account holds only free credit and this model or request does not qualify | Choose an eligible open-weight text model, lower `max_tokens`, or [add credit](https://heyely.si/credit?step=add) |
| `402 key_limit_reached`        | This API key hit its dollar cap                                           | Raise the limit in Developers or swap keys                                                       |
