Heabsy Code from $20/mo · See plans →

Kilo Code CLI on Qwen3.8 27B: Setup, Config Trap and a Measured Task

by

Published:

Kilo Code reads the same provider format as OpenCode: a heabsy block with the base URL https://api.heabsy.com/v1, the model qwen38 with its limits and prices, in ~/.config/kilo/kilo.json. Put it in the global file: a project-level kilo.json that references the key as {env:…} is dropped without an error, and Kilo runs without the provider. On a small Python task Kilo CLI 7.8.18 on Qwen3.8 27B made 6 and 8 model calls and cost $0.056 and $0.054 at our catalog prices on 11 November 2026.

Kilo Code is a coding agent for VS Code, JetBrains and the terminal. Its CLI is built on OpenCode, so it reads the same provider format, and any OpenAI-compatible API can be added in a few lines of config. Every step of its loop is one request to the model.

This tutorial connects the Kilo CLI to Qwen3.8 27B on our API, shows the one place where the config has to live, explains the setting that decides when Kilo compacts a long session, and runs one small task twice with every model call logged. For the VS Code extension, the Kilo Code integration page has the steps.

Where does the provider config go?

Install the CLI (the command is kilo) and put the provider in the global config, ~/.config/kilo/kilo.json:

npm install -g @kilocode/cli
{
  "$schema": "https://app.kilo.ai/config.json",
  "provider": {
    "heabsy": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Heabsy",
      "options": { "baseURL": "https://api.heabsy.com/v1", "apiKey": "{env:HEABSY_API_KEY}" },
      "models": {
        "qwen38": {
          "name": "Qwen3.8 27B",
          "limit": { "context": 1048576, "output": 32768 },
          "cost": { "input": 1.05, "output": 3.15, "cache_read": 0.08 }
        }
      }
    }
  },
  "model": "heabsy/qwen38",
  "compaction": { "threshold_percent": 20 }
}

The global file matters. In our runs Kilo CLI 7.8.18 rejected a project-level kilo.json that contained "apiKey": "{env:HEABSY_API_KEY}": it logged ConfigInvalidError … skipped config due to error, visible only with --print-logs, and then ran without the provider. The same file without apiKey was accepted. OpenCode, which Kilo is built on, takes the {env:…} reference in a project file; Kilo does not.

The cost block makes Kilo’s cost display match the bill, cached input included; we checked it against the gateway’s charge. Without it the cost shows as $0.

What did one task cost?

The task was a small Python module of our own, not an issue from a public project: durations.py turns strings like "2h30m" into seconds, and 5 of its 8 pytest tests failed (days, spaces between number and unit, upper-case units, a bare number, all of them together). Kilo got one instruction: make all tests pass without changing them, add error handling for invalid input and one new test for it. We ran Kilo CLI 7.8.18 twice on 4 November 2026, each time on a clean copy:

kilo run --auto -m heabsy/qwen38 "Make all tests pass without changing them; add error handling for invalid input and one new test for it."

--auto approves every action. Without it, Kilo asks before shell commands that are not on its allowed list, and a run without a terminal cannot answer. Afterwards we ran pytest ourselves, checked that the original tests were untouched and fed the parser invalid input.

Run 1 Run 2
Result 9 passed, tests untouched, 1 new test 9 passed, tests untouched, 1 new test
Model calls / tool calls 6 / 10 8 / 11
Input tokens, of them cached 122,115, 102,872 (84%) 160,232, 136,320 (85%)
Output tokens, of them reasoning 8,883, 6,901 (78%) 5,829, 4,021 (69%)
Largest single request 26,674 tokens 23,643 tokens
Cost at catalog prices $0.0564 $0.0544
Wall-clock time 97 s 69 s

Both runs put the new test in a separate file and raise ValueError on input such as "", "abc", "5x" or "2h-5m". Kilo’s requests are the largest of the three agents we ran, because every one carries 23 tools and a system prompt of about 16,000 tokens. And the CLI took 20–28 seconds to start before the first request went out, which is part of the wall-clock time above.

Where the $0.0564 of the first run went:

  • Fresh input, $0.0202. 19,243 tokens: the first request, with its large system prompt, and the new part of each later one.
  • Cached input, $0.0082. 102,872 tokens that each request repeated from the one before.
  • Output, $0.0280, of which reasoning $0.0217. Qwen3.8 27B thinks before each tool call, and that thinking is billed as output.

The same task in Cline and OpenCode is measured the same way.

Get an API key and run Kilo on your own code: Qwen3.8 27B is free for 7 days, no card. After that you pay per token, and your first top-up gets $5 extra. Free requests run at lower priority at peak times.

When does Kilo compact a long session?

Every call sends the whole session again, so a call costs more as the session grows. By default Kilo CLI compacts like OpenCode: when the session reaches limit.context minus the output reserve, which is limit.output or 32,000 tokens, whichever is smaller. Without limit.context there is no automatic compaction.

Kilo adds one setting OpenCode does not have: compaction.threshold_percent, the share of the window at which compaction starts. Cost of one call at the compaction point on Qwen3.8 27B (1,048,576-token window), with 88% of the input cached and 1,000 tokens of output, close to the runs above:

Setting Compacts at One call
default 1,016,576 tokens $0.2028
threshold_percent: 40 419,430 tokens $0.0855
threshold_percent: 20 209,715 tokens $0.0443

The largest request in our runs was 26,674 tokens and cost about $0.0084, so compaction never came near. The config above uses 20: the full window stays available, and no call costs much over $0.044 before Kilo compacts. Each compaction rewrites the history, so the call after it is billed at the fresh-input price; raise the threshold if sessions compact too often. The cost formula behind these numbers is in What an agent step costs.

What goes wrong, and how do you fix it?

Symptom Fix
Heabsy is missing from the model list, no error shown The provider is in a project kilo.json with {env:…}. Move it to ~/.config/kilo/kilo.json, or run with --print-logs to see the rejection.
kilo run stops at a shell command Add --auto.
404 Not Found baseURL must be exactly https://api.heabsy.com/v1; the provider must use the OpenAI Compatible package, not the Responses API.
The session cost shows $0 Add the cost block to the model, with cache_read.
Long sessions fail with a context error Add limit.context and limit.output; without them Kilo does not compact.

Where does your code go?

From Kilo on your machine straight to api.heabsy.com. Qwen3.8 27B runs on GPUs we operate in the European Economic Area, and prompts and completions are not stored; we keep what billing needs: the model, the token counts and the time.

Method

  • Prices: our model catalog on 11 November 2026 (Qwen3.8 27B): $1.05 input, $0.08 cached input, $3.15 output per million tokens.
  • Runs: Kilo CLI 7.8.18 (@kilocode/cli), model qwen38 on https://api.heabsy.com/v1, two runs on clean copies of the same module, in parallel with other coding agents on 4 November 2026 between 10:02 and 10:13 UTC.
  • Counting: every request went through a logging proxy to our API; tokens are from the usage block of each response, cost is tokens times catalog prices. Kilo was also checked directly against the API without the proxy.
  • Compaction: from the Kilo CLI 7.8.18 source; threshold_percent is checked before each request.
  • Checks: pytest after each run, a comparison of the original tests before and after, and a separate set of invalid inputs the agent had not seen.

FAQ

Why does Kilo Code ignore my custom provider?+
Most likely the provider is in a project-level kilo.json that references the key as `{env:HEABSY_API_KEY}`. Kilo CLI 7.8.18 rejects such a file as invalid and carries on without it; the message only shows up with `--print-logs`. Move the provider to the global `~/.config/kilo/kilo.json`, or keep the project file without `apiKey`.
How do I run Kilo Code without the TUI?+
Use `kilo run --auto -m heabsy/qwen38 "your task"`. `--auto` approves every action; without it Kilo asks before shell commands that are not on its allowed list, and a run without a terminal cannot answer. `--format json` prints one event per step, with tokens and cost.
How do I make Kilo Code compact earlier?+
Set `compaction.threshold_percent` in the config. Without it Kilo compacts at `limit.context` minus the output reserve (up to 32,000 tokens), which for Qwen3.8 27B's full 1,048,576-token window is 1,016,576 tokens, where one call costs about $0.20. With `threshold_percent: 20` it compacts at 209,715 tokens and keeps calls near $0.044.
What does a Kilo Code task cost on Qwen3.8 27B?+
Our measured task, a small Python module with five failing tests, cost $0.0564 and $0.0544 in two runs of Kilo CLI 7.8.18, with 6 and 8 model calls. 84–85% of the input came from the prompt cache, and reasoning was 69–78% of the output.