Prerequisites
- A Token Factory API key. See Authentication.
- Kilo Code 7.8.8 or later: the CLI
(
npm install -g @kilocode/cli) or the VS Code or JetBrains extension. - A model from the Token Factory catalog.
Context window and compaction
Kilo Code does not read limits from the endpoint, so each model declares them underlimit:
limit.contextis the model’scontext_window.limit.outputis the model’smax_output_tokens. Kilo Code sendsmax_tokens= the smaller of this and its built-in 32,000-token cap, reduced only when the context is nearly full.limit.inputsets where Kilo Code compacts: it summarizes the conversation once a request reacheslimit.inputminus 20,000 tokens (its defaultcompaction.reservedwhile the output cap is at least 20,000). Withoutlimit.input, Kilo Code compacts only atlimit.context − max_tokens, with no headroom.
(context_window − max_tokens) / 1.15, rounded down, and limit.input is
that value plus 20,000:
GET /v1/models reports each model’s current context_window and
max_output_tokens.
1
Store the API key
Export the key in your shell profile. The configuration below reads it with
{env:CORVEX_API_KEY}, which Kilo Code resolves only in the global
configuration file.2
Add the provider configuration
Add the provider to the global configuration file,
In the extensions you can also add the provider from the settings (gear
icon) under Providers → Custom provider, with the Base URL
~/.config/kilo/kilo.jsonc:kilo.jsonc
https://api.tokenfactory.corvex.cloud/v1 and OpenAI Compatible as the
API. Then add the limit entries above to the same file and reload the
window (Developer: Reload Window in VS Code).3
Select the model and verify the connection
New sessions in the extension can start on Kilo Code’s own model router,
which does not use Token Factory. Select the model button under the chat box
and choose a model in the Corvex Token Factory group. The context bar
shows the configured window (
393.2K for zai-org/GLM-5.3).From the CLI, run one prompt non-interactively:kilo models corvex --verbose prints the limits Kilo Code loaded for each
model.Compatibility notes
- Model IDs. Use the exact
idfromGET /v1/models. IDs are case-sensitive and usenamespace/modelformat; add thecorvex/provider prefix only when you select a model on the command line. - Output budget. Reasoning tokens count toward the 32,000-token budget. The
KILO_EXPERIMENTAL_OUTPUT_TOKEN_MAXenvironment variable changes the cap; recompute the compaction window if you change it. - Context length. If a long task still exceeds the model’s window, the
gateway returns
context_length_exceeded. Start a new task or shorten the context. See Errors. - Debug output.
kilo debug configprints the resolved API key in plain text. Do not paste its output into issues or logs.
Related documentation
- Connect OpenCode — the same configuration format in OpenCode.
- Use the OpenAI SDK — the same endpoint from Python or TypeScript.
- Errors — authentication, rate-limit, and validation responses.