What is Kilo Code?
Kilo Code, from Kilo AI, is an open-source AI coding agent available in VS Code, JetBrains, and the CLI, with configurable model providers.
This Kilo Code setup guide uses its OpenAI-compatible provider controls to connect TokenHub. Start with a read-only task, then validate edits and commands with a tool-capable model. Kilo Code exposes related workflows in VS Code, JetBrains, and the CLI, but configuration scope can differ between those clients. Confirm the active profile and provider in the client you are actually using, then compare model quality, tool reliability, latency, context length, and cost on a representative repository task.
Kilo Code can route model requests through TokenHub's OpenAI compatible API gateway. Keep the official installation flow, then replace only the API key, Base URL, and model ID.
The TokenHub endpoint used by this guide is https://us-api.tokenhub.com/v1/chat/completions.
When to use it
Start in a small repository or test project. First ask the tool to read files, explain code, or produce a plan; only then enable edits, terminal commands, or agent automation.
Install or open the tool
Follow the official Kilo Code documentation to install or open the tool. If menus or command names differ, prefer the current official documentation.
For CLI tools, confirm the executable works before adding TokenHub credentials:
# open the tool, then open its model or provider settingsPrepare TokenHub credentials
Create a TokenHub API key and choose a model from the TokenHub model list that fits this tool.
export TOKENHUB_API_KEY="sk-..."Keep the key in your local shell, IDE secret storage, or the secure API key field of the tool. Do not commit it to the repository.
Configure TokenHub persistently
Use the tool configuration file or settings page first. This avoids the common problem where a terminal sees the environment variable but the IDE, plugin, or new window does not.
Provider values
| Field | Value |
|---|---|
| Provider | OpenAI Compatible or Custom |
| Base URL | https://us-api.tokenhub.com/v1 |
| API Key | The value of TOKENHUB_API_KEY |
| Model | gpt-4.1 or another TokenHub model ID |
Settings file locations
| Field | Value |
|---|---|
| Provider settings | Kilo Code → Providers → Custom provider |
| Provider API | OpenAI Compatible |
| Required fields | Provider ID, Base URL, API Key, Model ID |
Save the custom provider in Kilo Code, let it fetch /v1/models when available, or add the TokenHub model ID manually. Verify a chat request before enabling agent edits.
If the tool separates chat, edit, apply, and fast models, use the same TokenHub model for the first test. Split models later by cost, latency, and reasoning strength.
Temporary environment variables for debugging
Use the settings UI first when the extension owns the schema. It stores the same values in a user-level settings file and avoids guessing private keys that may change between releases.
Use temporary variables only to confirm the key, network, and model name. After validation, move the same values into the persistent configuration above.
Verify the connection
Test with a read-only prompt first, confirming that the model can read context without changing files. Then test edits, Apply, or agent tasks.
Read the project README and summarize it in three sentences. Do not modify any files.After a successful prompt, check TokenHub request logs for model name, endpoint, token usage, and billing group.
Troubleshooting
| Symptom | Fix |
|---|---|
| 401 or authentication failure | Confirm TOKENHUB_API_KEY is valid and saved in the same terminal, IDE, or client profile. |
| 404 or model not found | Use a model ID that exists in your TokenHub workspace and matches the selected protocol. |
| Wrong endpoint | Keep the Base URL exactly as shown. OpenAI-compatible tools usually need /v1; Claude-compatible tools usually do not. |
| Request timeout | Check network access to https://us-api.tokenhub.com, proxy settings, and workspace allowlists. |
| Tool uses another model | Recheck every chat, edit, apply, fast, and autocomplete model slot. |
Choose a compatible Kilo Code model
Kilo Code custom API FAQ
Why cannot Kilo Code read the TokenHub model list?
A failed automatic model discovery does not necessarily mean the API is unavailable. Copy the exact model ID from TokenHub and enter it manually.
What if Chat works but Tab completion does not?
Chat and Tab can use different model slots. Configure a low-latency, completion-compatible model for Tab and verify it separately.
Why can the IDE not read TOKENHUB_API_KEY?
An IDE launched from a desktop icon may not inherit terminal environment variables. Use Kilo Code's secure API-key field to complete the initial verification.
Do Kilo Code CLI and IDE extensions share one model configuration?
They can use the same TokenHub model, but configuration scope and profiles may differ. Verify the Base URL, key, model, and active profile in each client.
What if Kilo Code can chat but cannot edit code?
Confirm that the model supports native tool calls and structured arguments, then check edit permissions and command approvals. Basic text generation does not validate the agent tool chain.
References
This setup is based on TokenHub and official documentation, last verified on 2026-09-04.