Skip to content
Sign Up Free
Coding and development

Kilo Code setup: API key, Base URL, and models

Install Kilo Code, configure the BetterToken Base URL and API key, choose an available model, and troubleshoot common errors. Practical guidance.

To connect Kilo Code to BetterToken, prepare an API key, enter the Base URL shown below, and choose a current Model ID from the model plaza.

Three steps to your first request

  1. Get a BetterToken API key and choose a Model ID in the model plaza.
  2. Add a Custom provider in Kilo Code’s Providers settings, choose OpenAI Compatible, then enter the API key, https://bettertoken.ai/v1, and Model ID.
  3. Save the settings, restart the extension, and send a short request in a new chat.

Key settings

FieldValue
API KeyBetterToken API key
Base URLhttps://bettertoken.ai/v1
ModelA current Model ID from the model plaza

Prerequisites

Sign up and get a BetterToken API Key

Already have an account? Sign in, top up, then create a key in the console.

Additional requirements

  • VS Code installed

Install

If Kilo Code is already installed, go directly to Manual setup to enter your BetterToken API Key, Base URL, and Model ID.

If you still need to install the extension or want the installation and regional-use background, read the Kilo Code installation and custom API guide, then return here for the current setup fields.

Manual setup

Complete this setup in the Kilo Code settings UI. You do not need to edit a configuration file.

FieldValue
API KeyBetterToken API key
Base URLhttps://bettertoken.ai/v1
ModelA current Model ID from the model plaza

Setup

Clear conflicting environment variables

Terminal window
unset OPENAI_API_KEY
unset OPENAI_BASE_URL

Open Kilo Code settings

Open Settings (gear icon), select Providers, and click Custom provider at the bottom of the list.

Configure the API provider

Fill in:

  • Provider ID → bettertoken
  • Display name → BetterToken
  • Provider API → OpenAI Compatible
  • Base URL → https://bettertoken.ai/v1
  • API Key → your BetterToken API Key
  • Models → manually add a model ID copied from the model plaza and use the same ID as its display name

Click Submit to save the provider. These are the VS Code extension fields in the official Custom Models guide.

Only configure extra headers when the official docs explicitly require them

The official Kilo Code material we checked mentions optional custom headers for OpenAI-compatible providers, but it does not treat User-Agent as a required BetterToken setup step.

If you are also using a custom gateway, tenant routing, observability, or caching layer, add headers only according to that upstream service’s official docs.

Restart Kilo Code

After changing the config, restart VS Code or reload the Kilo Code extension so the new settings take effect.

Verify the connection

Open a new Kilo Code chat and send a short prompt such as Reply with one word: OK. If the tool responds without an authentication or Model ID error, the first request succeeded. Restart VS Code or the extension after changing the configuration. If it fails, go directly to Common errors.

Kilo CLI

Install the official Kilo CLI separately from the extension. In macOS testing with a GPT model, Kilo CLI 7.8.17 completed text requests and file-reading tool calls through /v1/chat/completions.

Set your BetterToken API Key in the terminal:

Terminal window
export BETTERTOKEN_API_KEY="YOUR_API_KEY"

Create kilo.json in your project. Replace every YOUR_MODEL_ID with the exact ID from the model plaza:

{
"provider": {
"bettertoken": {
"npm": "@ai-sdk/openai-compatible",
"name": "BetterToken",
"options": {
"baseURL": "https://bettertoken.ai/v1",
"apiKey": "{env:BETTERTOKEN_API_KEY}"
},
"models": {
"YOUR_MODEL_ID": { "name": "YOUR_MODEL_ID" }
}
}
},
"model": "bettertoken/YOUR_MODEL_ID",
"permission": { "read": "allow", "edit": "deny", "bash": "deny" },
"agent": { "build": { "steps": 4 } }
}

Point KILO_CONFIG at that file and run a non-interactive text check:

Terminal window
export KILO_CONFIG="$PWD/kilo.json"
kilo run --format json -m bettertoken/YOUR_MODEL_ID "Reply with only: OK"

Check the final answer for OK. This configuration allows file reads and denies edits and shell commands. Passing the file through KILO_CONFIG makes it a trusted configuration source, where {env:...} references can expand. A project configuration loaded only from the repository does not expand environment variable references; keep the explicit KILO_CONFIG selection above.

Switch models

Open the model selector or change the Model field in the configuration. Use the exact Model ID from the model plaza, then restart the current session.

Common errors

ErrorWhat to check
401 or UnauthorizedCheck the BetterToken API key and remove leading or trailing spaces.
404Check the Base URL and do not append a specific endpoint path.
model not foundCopy a current Model ID from the model plaza.
Changes do not applySave the configuration and fully restart the tool.

Technical details

Protocol, endpoint, and internal provider fields

This setup uses https://bettertoken.ai/v1. The tool appends the OpenAI-compatible endpoint path. Do not add /chat/completions or /responses unless a specific field explicitly requires it.