Skip to content

Claude Code

Anthropic's Claude Code CLI is the tightest integration in this list. It talks the Anthropic Messages protocol natively, and CodeGate exposes exactly that protocol at /v1/messages. Two environment variables and you are running.

1. Install Claude Code

bash
npm install -g @anthropic-ai/claude-code

Verify:

bash
claude --version

If you do not have Node installed, use whichever install path you prefer for the official CLI.

2. Get a CodeGate API key

Open codegate.dev/console/token and click Add Token. Copy the sk-... value.

If you have not added credit yet, do that at Console, Top Up first. A few dollars will cover a lot of Claude Code prompts.

3. Point Claude Code at CodeGate

Set two environment variables:

bash
export ANTHROPIC_BASE_URL="https://codegate.dev"
export ANTHROPIC_API_KEY="sk-..."

That is it. Claude Code will now hit POST https://codegate.dev/v1/messages for every prompt, which is CodeGate's Anthropic-compatible endpoint.

Persist across shells

Add the two export lines to ~/.zshrc (macOS default), ~/.bashrc (Linux default), or your shell's equivalent. Reopen the terminal or run source ~/.zshrc.

For a per-project override, put them in a .env file and load it with direnv or dotenv.

4. Verify

bash
claude "Explain what CodeGate is in one sentence."

You should see a short answer come back within a second or two. If it hangs, the key or the base URL is likely off, see the troubleshooting section below.

You can double-check the endpoint with a plain curl using the same environment variables:

bash
curl "$ANTHROPIC_BASE_URL/v1/messages" \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{"model":"claude-opus-4-8","max_tokens":128,"messages":[{"role":"user","content":"Say hi."}]}'

5. Model selection

Claude Code sends the model name in the request. Any Claude model CodeGate supports is valid:

ModelInputCache writeCache hitOutputWhen to use it
claude-fable-5$1.00$1.25$0.10$5.00Frontier tier.
claude-opus-4-8$0.50$0.63$0.05$2.50Deepest reasoning.
claude-sonnet-5$0.30$0.38$0.03$1.50Best balance. Good default.
claude-haiku-4-5-20251001$0.08$0.10$0.008$0.40Fast and cheap.

Prices are per 1M tokens, already at the 85% discount. See Models and Pricing for detail.

Set the default in Claude Code with:

bash
claude config set default-model claude-sonnet-5

Troubleshooting

401 Unauthorized. The ANTHROPIC_API_KEY is missing, wrong, or truncated. Print echo $ANTHROPIC_API_KEY and confirm it starts with sk- and looks intact.

403 or 404 on /v1/messages. ANTHROPIC_BASE_URL is set to something other than https://codegate.dev. Check with echo $ANTHROPIC_BASE_URL. It must be the bare host, no trailing slash, no /v1.

402 Payment Required. Balance ran out. Top up at Console, Top Up.

Empty responses or hangs. Rare, but if it happens, retry once. CodeGate fails over between upstreams, so a second attempt almost always succeeds. Persistent failures: join the Discord.

Next

Built on new-api. Served by CodeGate.