# Kilo Code

Source: https://staging-docs.aiand.com/integrations/kilo-code/

[Kilo Code](https://kilo.ai) is an open-source coding agent for VS Code, JetBrains, and the terminal. Connect ai& as a custom OpenAI-compatible provider to use the same models and configuration on every surface.

<Aside type="note">
  For agentic repository work, start with `zai-org/glm-5.3`. For a cheaper, faster loop, use
  `deepseek-ai/deepseek-v4-flash`. Both support tool calling.
</Aside>

## Prerequisites

- Kilo Code for [VS Code](https://marketplace.visualstudio.com/items?itemName=kilocode.Kilo-Code), [JetBrains](https://plugins.jetbrains.com/plugin/28350-kilo-code), or the CLI
- An [ai& API key](https://console.aiand.com/api-keys)

## VS Code and JetBrains

1. Open Kilo Code settings:
   - **VS Code:** click the gear icon in the Kilo Code sidebar.
   - **JetBrains:** open **Settings → Tools → Kilo Code**.
2. Open **Providers**, scroll to the bottom, and select **Custom provider**.
3. Enter:

   | Setting      | Value                      |
   | ------------ | -------------------------- |
   | Provider ID  | `aiand`                    |
   | Display name | `ai&`                      |
   | Provider API | **OpenAI Compatible**      |
   | Base URL     | `https://api.aiand.com/v1` |
   | API key      | Your ai& API key           |

4. Select models from the fetched list, or add an exact ID from the [model catalog](/models/catalog/).
5. Save the provider and choose `aiand/<model-id>` in Kilo's model picker.

<Aside type="caution">
  Keep the `/v1` suffix. Kilo appends `/chat/completions` and discovers models from `/models`.
</Aside>

## CLI

Install Kilo:

```bash
npm install -g @kilocode/cli
```

Set your API key:

<Tabs syncKey="os">
<TabItem label="macOS / Linux">

```bash
export AIAND_API_KEY="sk-your-aiand-api-key"
```

</TabItem>
<TabItem label="Windows (PowerShell)">

```powershell
$env:AIAND_API_KEY = "sk-your-aiand-api-key"
```

</TabItem>
</Tabs>

Create the global config at `~/.config/kilo/kilo.jsonc`:

```jsonc
{
  "$schema": "https://app.kilo.ai/config.json",
  "model": "openai-compatible/zai-org/glm-5.3",
  "provider": {
    "openai-compatible": {
      "options": {
        "apiKey": "{env:AIAND_API_KEY}",
        "baseURL": "https://api.aiand.com/v1",
      },
      "models": {
        "zai-org/glm-5.3": {
          "name": "GLM 5.3",
          "tool_call": true,
          "reasoning": true,
          "limit": {
            "context": 1048576,
            "output": 131072,
          },
        },
        "deepseek-ai/deepseek-v4-flash": {
          "name": "DeepSeek V4 Flash",
          "tool_call": true,
          "reasoning": true,
          "limit": {
            "context": 1048576,
            "output": 384000,
          },
        },
      },
    },
  },
}
```

<Aside type="caution">
  Put `{env:AIAND_API_KEY}` in the global config. Kilo deliberately ignores
  environment references in project-level `kilo.jsonc` files because a
  repository could otherwise redirect a secret to an arbitrary endpoint.
</Aside>

Run the interactive terminal UI:

```bash
kilo
```

Or run one task:

```bash
kilo run --auto -m openai-compatible/zai-org/glm-5.3 "inspect this repository and fix the failing test"
```

## Verify

Confirm Kilo can see the configured provider and model:

```bash
kilo models openai-compatible
kilo run --auto -m openai-compatible/zai-org/glm-5.3 "reply with only: ok"
```

## Troubleshooting

- **Models do not load** — confirm the base URL is exactly `https://api.aiand.com/v1` and re-enter the API key.
- **Unauthorized request** — create a new key in the [ai& console](https://console.aiand.com/api-keys) and update the provider or `AIAND_API_KEY`.
- **The CLI ignores `AIAND_API_KEY`** — keep the `{env:AIAND_API_KEY}` reference in the global config, not a project config.
- **The agent answers but cannot edit files** — choose a model with `tool_calling` in the [catalog](/models/catalog/) and allow Kilo's file tools when prompted.
- **Context usage is missing or compaction does not run** — add the model's `limit.context` and `limit.output` values from the [catalog](/models/catalog/) to `kilo.jsonc`.
