# Kilo Code Setup with AnonRouter

Configure Kilo Code with private, uncensored AI models through AnonRouter. Covers VS Code and CLI setup, API keys, model selection, and tool calling.

Source: https://docs.anonrouter.ai/kilo-code

Kilo Code can connect directly to AnonRouter through its custom
  OpenAI-compatible provider. Use the VS Code settings dialog or configure the
  terminal client with `kilo.jsonc`.

  > **The short version**
>
> Add a custom provider named **AnonRouter**, select **OpenAI Compatible**, and
> use `https://api.anonrouter.ai/v1` with your AnonRouter inference key. Choose
> a tool-capable model from our catalog, then select it in Kilo's model picker.

  ## 1. Create your AnonRouter key

  Create a dedicated inference key with **OpenAI-compatible access** enabled
  (on by default). Your account needs available credits or a subscription
  allowance. Set an optional **total credit limit** for the key to bound agent
  spending.

  [Create an API key](https://anonrouter.ai/home/api-keys)

  This connection uses a static bearer key and [compatibility mode](https://docs.anonrouter.ai/compatibility).
  A management key cannot run inference.

  ## 2. Connect in VS Code

  Install the current [Kilo Code extension](https://kilo.ai/docs/getting-started/installing),
  then open **Settings → Providers → Custom provider**. Enter:

  | Setting      | Value                                  |
  | ------------ | -------------------------------------- |
  | Provider ID  | `anonrouter`                           |
  | Display name | `AnonRouter`                           |
  | Provider API | **OpenAI Compatible**                  |
  | Base URL     | `https://api.anonrouter.ai/v1`         |
  | API key      | Your AnonRouter inference key          |
  | Models       | Select a tool-capable AnonRouter model |

  Kilo can fetch models from the endpoint after you enter the URL and key.
  Use **Fetch models** to retry, or enter an exact API ID from the
  [AnonRouter catalog](https://anonrouter.ai/models) manually. Click **Submit**,
  then choose your model in the model picker.

  Keep **OpenAI Compatible** selected for every model served through this
  connection, including Claude or GPT models. The protocol is determined by the
  AnonRouter endpoint, rather than the model's original vendor.

  These instructions follow Kilo's current provider dialog. Older extension
  releases used an **API Provider → OpenAI Compatible** dropdown; update Kilo if
  your settings differ.

  ## Alternative: configure the terminal client

  Install the current Kilo CLI:

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

  Choose a model, then merge the configuration into your global
  `~/.config/kilo/kilo.jsonc`:

  Example for DeepSeek V4.1 Flash Uncensored:

```json

{
  "$schema": "https://app.kilo.ai/config.json",
  "model": "anonrouter/coding",
  "provider": {
    "anonrouter": {
      "name": "AnonRouter",
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "https://api.anonrouter.ai/v1",
        "apiKey": "{env:ANONROUTER_API_KEY}"
      },
      "models": {
        "coding": {
          "id": "deepseek/deepseek-v4.1-flash-uncensored",
          "name": "DeepSeek V4.1 Flash Uncensored",
          "tool_call": true,
          "reasoning": true,
          "limit": {
            "context": 1000000,
            "output": 32000
          },
          "modalities": {
            "input": [
              "text",
              "image"
            ],
            "output": [
              "text"
            ]
          }
        }
      }
    }
  }
}

```

Choose another model from https://anonrouter.ai/models and use its advertised capabilities and limits.

  `coding` is your local alias; `id` is the model ID sent to AnonRouter. The
  configuration includes image input for vision-capable models and the full
  advertised context window. Its output budget starts at 32,000 tokens, or the
  model's limit if lower, following OpenCode's fallback budget. Add other model
  aliases under `models` to make more choices available.

  Set the credential in the environment that launches Kilo:

```bash
export ANONROUTER_API_KEY=ar_REPLACE_WITH_YOUR_API_KEY
kilo
```

  Restart after editing the configuration and open `/models`. Select
  `anonrouter/coding`. Start with a harmless text request, followed by a read-only
  tool task in a test project.

  > **Keep environment references in global config**
>
> Kilo resolves `{env:ANONROUTER_API_KEY}` only in trusted configuration,
> including `~/.config/kilo/`. Putting this reference in a repository's
> `kilo.jsonc` does not authenticate the provider. Keep live credentials out of
> project files and review settings exports before sharing them.

  Kilo's current extension and CLI share configuration. The usual project
  locations are `kilo.jsonc` or `.kilo/kilo.jsonc`; project settings override
  global settings. Use the global file for the credential configuration above.

  ## Choose models and tools

  Check **tool calling**, context size, output limits, pricing, and privacy labels
  in the AnonRouter catalog. A text reply alone does not prove that the model can
  drive an agent's tools.

  AnonRouter transports tool definitions and model tool calls. Kilo executes
  files, shell commands, and connected MCP tools in its own environment. Review
  **Settings → Auto-Approve** and keep editing, shell access, and sensitive tools
  set to **Ask** while checking a new setup.

  Compatibility mode accepts user image inputs on vision-capable routes. Only
  add `"image"` to the model's input modalities when its AnonRouter route
  advertises vision. Image output from tools is a separate capability; do not
  assume a browser screenshot workflow works from model discovery alone.

  ## Privacy and spending

  Kilo may send selected source files, repository instructions, tool definitions,
  terminal output, and conversation history to AnonRouter and the selected model
  provider. Exclude secrets from agent context and review connected tools.

  The compatibility broker temporarily sees key identity and plaintext together.
  AnonRouter does not intentionally retain prompts or responses, but this flow
  is not unlinkable like native private tickets. Kilo's own local history,
  telemetry, sharing, and remote features have their own settings; AnonRouter's
  content-retention policy does not control them.

  Use a dedicated key with a total credit limit and review usage during longer
  tasks. Local cost estimates and permission prompts do not replace the
  AnonRouter key cap.

  ## Troubleshooting

  ### 401 or 403 response

  Verify the key and **OpenAI-compatible access** setting. For the CLI, confirm
  the environment variable is available to the Kilo process and its reference
  is in trusted global configuration.

  ### 404 response

  Use `https://api.anonrouter.ai/v1` as the base URL and the Chat Completions
  protocol. Leave `/chat/completions` out of this configuration.

  ### A model is missing or rejected

  Retry **Fetch models**, or add the exact API ID manually. In CLI configuration,
  ensure there is a model under `provider.anonrouter.models` and that the selected
  alias matches it. Restart Kilo after editing.

  ### Tools fail or the context overflows

  Verify the route's tool capability, Kilo's local permissions, and the model's
  configured token limits. Reduce active context before retrying a request that
  exceeds the model's window.

  ## Sources and further reading

  * [Kilo: OpenAI-compatible providers](https://kilo.ai/docs/ai-providers/openai-compatible)
  * [Kilo: Custom models and token limits](https://kilo.ai/docs/code-with-ai/agents/custom-models)
  * [Kilo: CLI installation and configuration](https://kilo.ai/docs/code-with-ai/platforms/cli)
  * [Kilo: Shared settings and configuration files](https://kilo.ai/docs/getting-started/settings)
  * [Kilo: Tool permissions](https://kilo.ai/docs/getting-started/settings/auto-approving-actions)
  * [AnonRouter compatibility mode](https://docs.anonrouter.ai/compatibility)

  AnonRouter is an independent service and is not affiliated with Kilo Code.
