plaingateway
Integrations

Claude Code

Use plaingateway, the free OpenRouter alternative, in Claude Code: one settings block, the provider's list price for tokens and nothing on top.

Claude Code is Anthropic's coding agent for the terminal. It speaks the Anthropic Messages API and accepts a gateway through ANTHROPIC_BASE_URL. plaingateway answers that API and translates each request for the model you pick, so Claude Code needs one settings block and one key.

Paste this

json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.plaingateway.com",
    "ANTHROPIC_AUTH_TOKEN": "sk-pg-v1-...",
    "ANTHROPIC_MODEL": "openai/gpt-5.6-luna",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "openai/gpt-5.6-luna",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "openai/gpt-5.6-luna",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "openai/gpt-5.6-luna"
  }
}

Where the file lives

Put the block in ~/.claude/settings.json, which applies to every project. If the file already has an env object, add these keys to it. Never put the key in a project's .claude/settings.json, because that file is committed with the repository. Then start Claude Code with claude.

What each line does:

  • ANTHROPIC_BASE_URL is the host alone. Claude Code adds /v1/messages itself.
  • ANTHROPIC_AUTH_TOKEN sends your key as Authorization: Bearer, which the gateway reads.
  • ANTHROPIC_MODEL is the model the session starts on.
  • The three ANTHROPIC_DEFAULT_*_MODEL lines replace the opus, sonnet and haiku aliases. Claude Code uses the haiku one for background work, so all three need a model that answers.

For one terminal session instead, export the same variables and run claude:

sh
export ANTHROPIC_BASE_URL="https://api.plaingateway.com"
export ANTHROPIC_AUTH_TOKEN="sk-pg-v1-..."
export ANTHROPIC_MODEL="openai/gpt-5.6-luna"
export ANTHROPIC_DEFAULT_OPUS_MODEL="openai/gpt-5.6-luna"
export ANTHROPIC_DEFAULT_SONNET_MODEL="openai/gpt-5.6-luna"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="openai/gpt-5.6-luna"
claude

When the settings file and a shell export set the same variable, the settings file wins. Run /status in Claude Code: the Anthropic base URL line shows https://api.plaingateway.com.

Get a key

  1. Sign up at plaingateway.com/signup and click the link in the confirmation email.
  2. Open Keys, press New key and copy it. It starts with sk-pg-v1- and is shown once.
  3. Add credits by card on Credits. Requests are paid from it.

Check it works

Send the request Claude Code sends, to the same host with the same model:

sh
export PLAINGATEWAY_API_KEY="sk-pg-v1-..."
curl -i https://api.plaingateway.com/api/v1/messages \
  -H "Authorization: Bearer $PLAINGATEWAY_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -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). Each model's price is on Models.

Limits today

  • Only openai/ and deepseek/ models answer today; Claude models do not. The anthropic/ ids on Models return an error until they answer. Claude Code runs on an openai/ or deepseek/ model through the gateway's translation: tools, system prompts, images and streaming are translated. Anthropic builds Claude Code for Claude, so results on another model can differ. Other ids that answer include openai/gpt-6.1-sol, deepseek/deepseek-v4-pro and deepseek/deepseek-v4.1-flash.
  • 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

The base URL is the host alone. The base URL other tools take, https://api.plaingateway.com/api/v1, as ANTHROPIC_BASE_URL becomes /api/v1/v1/messages and gets 404.

Use ANTHROPIC_AUTH_TOKEN, not only the base URL. With the base URL set and no gateway key, Claude Code keeps a saved claude.ai login as its credential, and the gateway answers 401.

A model id without the author prefix. Claude Code's own names, such as claude-sonnet-5-5 or sonnet, are not plaingateway ids. Set all four model lines to full author/slug ids.

Moving from OpenRouter

Keep your model ids. Change ANTHROPIC_BASE_URL to https://api.plaingateway.com and ANTHROPIC_AUTH_TOKEN to a plaingateway key. The full guide: Migrate from OpenRouter.

Claude Code's own reference for these settings: code.claude.com/docs/en/llm-gateway-connect.