---
title: "Kilo Code"
description: "Use plaingateway, the free OpenRouter alternative, in Kilo Code: one custom provider, the provider's list price for tokens and nothing on top."
---

# Kilo Code

Kilo Code is a coding agent for VS Code and the terminal. It talks to any OpenAI-compatible API through a custom provider, so plaingateway needs one provider entry and one key. Model ids are OpenRouter's, for example `openai/gpt-5.6-luna`.

## Paste this

Open **Settings** (the gear icon), go to the **Providers** tab, scroll to the bottom and press **Custom provider**. Fill in the dialog. Copy each value from the block:

```text
Provider ID: plaingateway
Display name: plaingateway
Provider API: OpenAI Compatible
Base URL: https://api.plaingateway.com/api/v1
API key: sk-pg-v1-...
Models: openai/gpt-5.6-luna
```

Press **Submit**. The model then shows in the model picker as `plaingateway/openai/gpt-5.6-luna`.

## Where the setting lives

Kilo Code writes the provider to its config file: `~/.config/kilo/kilo.json` for every project, or `kilo.json` at the project root for one. Keep the key out of a project file you commit.

## Get a key

1. Sign up at [plaingateway.com/signup](https://plaingateway.com/signup) and click the link in the confirmation email.
2. Open [Keys](https://plaingateway.com/settings/keys), press **New key** and copy it. It starts with `sk-pg-v1-` and is shown once. Paste it into **API key**.
3. Add credits by card on [Credits](https://plaingateway.com/settings/credits). Requests are paid from it.

## Check it works

Send one short task in Kilo Code, or one request from a terminal to the same base URL with the same model:

```sh
export PLAINGATEWAY_API_KEY="sk-pg-v1-..."
curl -i https://api.plaingateway.com/api/v1/chat/completions \
  -H "Authorization: Bearer $PLAINGATEWAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-5.6-luna",
    "max_tokens": 32,
    "messages": [
      {"role": "user", "content": "Say hello in five words."}
    ]
  }'
```

A 200 means the key and the base URL work. Three things in the answer tell you what happened: the `X-PG-Host` header names the provider that served it, `X-PG-Cost-USD` is the charge, and `usage.cost` in the body is the same charge. To find the request, open Logs in your API key's workspace. Logs keeps requests for seven days.

## What it costs

You pay the provider's official list price for tokens, and plaingateway adds nothing on top: 0% platform fee, no markup, no subscription, free with your own provider keys. You can earn up to 20% bonus credit, added to your balance when you add money and never taken off the token price: each person you invite gives you 1% bonus credit once they have paid $20 in total, up to 20%, so $100 paid gets up to $120 of credit. The person you invite gets 5% bonus credit on their first top-up, and you earn 10% of what they pay ([How referral works](../referral/how-it-works.md)). Each model's price is on [Models](https://plaingateway.com/models).

## Limits today

- **Only `openai/` and `deepseek/` models answer today.** Kilo Code fetches the model list from `https://api.plaingateway.com/api/v1/models` once the base URL is in, and that list holds more models than answer today. Pick an `openai/` or `deepseek/` id; any other id returns an error. Ones that answer include `deepseek/deepseek-v4.1-flash`, `deepseek/deepseek-v4-pro` and `openai/gpt-6.1-sol`.
- **Credit is prepaid.** Requests are paid from a balance you add by card. With no balance the gateway answers 402. Each request first holds its largest possible cost, the prompt plus the maximum output; on a low balance it holds an eighth of what is left and shortens the answer to fit, so a long task can get shorter answers, then 402, before the balance is spent.

## Gotchas

**Pick OpenAI Compatible.** It sends chat completions, the same format as the test request above. The base URL on this page is for that choice.

**The base URL ends in `/api/v1`.** Kilo Code adds `/chat/completions` itself.

**The model id needs the author prefix.** `gpt-5.6-luna` alone returns 400. Copy the full `author/slug` id from [Models](https://plaingateway.com/models).

## Moving from OpenRouter

Keep your model ids. Add the custom provider above, with the base URL `https://api.plaingateway.com/api/v1` and a plaingateway key. The full guide: [Migrate from OpenRouter](../migrate/from-openrouter.md).

Kilo Code's own reference for this setting: [kilo.ai/docs/ai-providers/openai-compatible](https://kilo.ai/docs/ai-providers/openai-compatible).
