---
title: "Aider"
description: "Use plaingateway, the free OpenRouter alternative, in Aider: three lines of config, the provider's list price for tokens and nothing on top."
---

# Aider

Aider is a coding agent for the terminal that edits the files in your git repository. It talks to any OpenAI-compatible API, so plaingateway needs three lines of config and one key. Model ids are OpenRouter's, for example `openai/gpt-5.6-luna`, with one extra `openai/` in front (see below).

## Paste this

```yaml
openai-api-base: https://api.plaingateway.com/api/v1
openai-api-key: sk-pg-v1-...
model: openai/openai/gpt-5.6-luna
```

## Where the file lives

Save the lines as `.aider.conf.yml` in your home directory. Aider also reads the file from the root of your git repository and from the current directory, but a file in the repository can be committed with the key in it, so keep this one in your home directory. Then run `aider` in your project.

The same setup as environment variables, for one terminal session:

```sh
export OPENAI_API_BASE="https://api.plaingateway.com/api/v1"
export OPENAI_API_KEY="sk-pg-v1-..."
aider --model openai/openai/gpt-5.6-luna
```

## Why the model starts with `openai/openai/`

Aider reads the first `openai/` as "send this to the OpenAI-compatible server" and drops it. It sends the rest, `openai/gpt-5.6-luna`, as the model id. So put `openai/` in front of any plaingateway model id, for example `openai/deepseek/deepseek-v4.1-flash`.

## 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.
3. Add credits by card on [Credits](https://plaingateway.com/settings/credits). Requests are paid from it.

## Check it works

Send one request to the same base URL with the model id the gateway receives (one `openai/`, not two):

```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. The request also shows on the [Activity](https://plaingateway.com/activity) page.

## 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.** [Models](https://plaingateway.com/models) lists more ids; 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 session can get shorter answers, then 402, before the balance is spent.

## Gotchas

**A warning about an unknown model.** Aider does not know plaingateway's model ids, so it prints a model warning at start and guesses the context size and price. The requests still work. Aider's own guide to the warning: [aider.chat/docs/llms/warnings.html](https://aider.chat/docs/llms/warnings.html).

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

**A 401 means the key.** Check that `openai-api-key`, or `OPENAI_API_KEY` if you use the variables, holds the whole plaingateway key, from `sk-pg-v1-` to the last character. An OpenAI key left over in your shell gets 401.

## Moving from OpenRouter

Keep your model ids. Replace `openrouter/` at the start of the Aider model name with `openai/`, set `openai-api-base` and `openai-api-key` as above. The full guide: [Migrate from OpenRouter](../migrate/from-openrouter.md).

Aider's own reference for this setting: [aider.chat/docs/llms/openai-compat.html](https://aider.chat/docs/llms/openai-compat.html).
