> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tokenlab.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Kilo Code

> Connect Kilo Code and Kilo CLI to TokenLab

## Overview

<Note>
  **Type**: IDE and CLI coding agent

  **Primary Path**: OpenAI-compatible Chat Completions

  **Support Confidence**: Official custom-provider path
</Note>

[Kilo Code](https://kilo.ai/docs/ai-providers/openai-compatible) supports custom OpenAI-compatible providers in its VS Code extension and Kilo CLI. Both clients share the same provider and model configuration.

## Install

For VS Code, search for **Kilo Code** in Extensions and install the pre-release channel. Kilo documents that channel as the current stable, recommended extension.

For the CLI, run:

```bash theme={null}
npm install -g @kilocode/cli
kilo --version
```

## Configure in the UI

1. Open Kilo Code **Settings → Providers**.
2. Scroll down and click **Custom provider**.
3. Use these values:

| Field        | Value                        |
| ------------ | ---------------------------- |
| Provider ID  | `tokenlab`                   |
| Display name | `TokenLab`                   |
| Provider API | **OpenAI Compatible**        |
| Base URL     | `https://api.tokenlab.sh/v1` |
| API key      | Your TokenLab API key        |
| Model        | Select or add `kimi-k3`      |

Kilo automatically queries TokenLab's `/v1/models` endpoint after the Base URL and key are entered. Click **Submit**, then choose `tokenlab/kimi-k3` in the model picker.

## Configure the CLI

Store secrets in an environment variable:

```bash theme={null}
export TOKENLAB_API_KEY="sk-your-tokenlab-key"
```

Add this to the trusted global config at `~/.config/kilo/kilo.jsonc`:

```jsonc theme={null}
{
  "$schema": "https://app.kilo.ai/config.json",
  "model": "openai-compatible/kimi-k3",
  "provider": {
    "openai-compatible": {
      "options": {
        "apiKey": "{env:TOKENLAB_API_KEY}",
        "baseURL": "https://api.tokenlab.sh/v1"
      },
      "models": {
        "kimi-k3": {
          "name": "Kimi K3",
          "tool_call": true,
          "reasoning": true,
          "modalities": {
            "input": ["text", "image"],
            "output": ["text"]
          },
          "limit": {
            "context": 1048576,
            "output": 131072
          }
        }
      }
    }
  }
}
```

<Warning>
  Kilo resolves `{env:...}` only in trusted global or managed configuration. Do not put an API key directly in a project `kilo.jsonc` that may be committed to Git.
</Warning>

## Verify

Restart Kilo after editing global configuration, then run:

```bash theme={null}
kilo models
kilo --model openai-compatible/kimi-k3
```

Ask Kilo to inspect a file before approving write or shell actions.

## Troubleshooting

<AccordionGroup>
  <Accordion title="Models do not appear">
    Confirm the Base URL ends in `/v1`, the key is active, and `kilo models` lists the configured provider. Add `kimi-k3` manually if model discovery is unavailable.
  </Accordion>

  <Accordion title="Context compaction does not run">
    Custom models need explicit `limit.context` and `limit.output` values. Keep the limits aligned with TokenLab's current model metadata.
  </Accordion>

  <Accordion title="The model cannot edit or run tools">
    Confirm `tool_call` is `true`, then review Kilo's permission settings for the current project.
  </Accordion>
</AccordionGroup>
