Clients / Claude Code

Clients

Claude Code

Use goodapi in Claude Code — set ANTHROPIC_BASE_URL and your key, choose models, and fix common problems.

Updated

Claude Code uses the Anthropic Messages API and needs a key from the Claude Max group.

One-off use

Set environment variables in your terminal, then start Claude Code:

bash
export ANTHROPIC_BASE_URL="https://api.goodapi.tech"
export ANTHROPIC_AUTH_TOKEN="sk-..."        # key from the Claude Max group
export ANTHROPIC_MODEL="claude-sonnet-5-5"   # optional, see below

claude

ANTHROPIC_BASE_URL has no /v1. You can also put the key in ANTHROPIC_API_KEY; either works.

Permanent setup

Add this to ~/.claude/settings.json, and every claude session will use goodapi:

json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.goodapi.tech",
    "ANTHROPIC_AUTH_TOKEN": "sk-...",
    "ANTHROPIC_MODEL": "claude-sonnet-5-5"
  }
}

To use it in one project only, put it in that project's .claude/settings.local.json instead. This file contains your key, so don't commit it.

Choosing models

  • Without ANTHROPIC_MODEL, Claude Code uses its own default model (usually the latest Opus), which costs more.
  • Set ANTHROPIC_MODEL to pin the main model; use a Claude Max group model from Models and pricing.
  • Switch models during a session with /model.
  • Claude Code uses a smaller model for some background tasks; set it with ANTHROPIC_DEFAULT_HAIKU_MODEL, for example claude-haiku-5-5.

Checking it works

bash
claude -p "Reply with exactly: ok"

If it replies ok and the request shows up on the Usage Logs page of the console, Claude Code is going through goodapi.

Troubleshooting

401, or the key is reported as invalid: check that the key is complete, hasn't expired and still has quota; see Error codes.

403 This token has no access to model: the key isn't from the Claude Max group, or model limits are enabled and the model isn't on the list. Claude Code uses both the main model and a smaller background model, so with model limits on, add both.

The Base URL includes /v1: Claude Code will request /v1/v1/messages and fail. Set ANTHROPIC_BASE_URL to just https://api.goodapi.tech.

Costs are higher than expected: every Claude Code request carries a long system prompt and conversation context. Give it its own key with a quota, and use ANTHROPIC_MODEL to pick a cheaper model.