← Integrations · Terminal agents

Claude Code setup via the Kiree gateway

Connect Claude Code to the kiree.net gateway through environment variables: an Anthropic-compatible endpoint, tokens billed from the shared balance.

Why the gateway

Why the direct setup does not cover every case

Claude Code normally authenticates against Anthropic servers directly. The gateway exposes an Anthropic-compatible endpoint; set the base URL and token variables so the CLI routes through kiree.net with one key and catalog models.

Setup

Steps to your first request

·

Get a key

Register on kiree.net and create a sk-… key in the console.

·

Set the variables

Add three lines to ~/.bashrc or ~/.zshrc: the gateway URL, the token, and an empty ANTHROPIC_API_KEY — otherwise the CLI tries Anthropic servers.

·

Pick a model

ANTHROPIC_MODEL sets the default model, e.g. claude-sonnet-4-6. Run claude and check the reply.

export ANTHROPIC_BASE_URL="https://kiree.net"
export ANTHROPIC_AUTH_TOKEN="sk-…"
export ANTHROPIC_API_KEY="" # must be empty
export ANTHROPIC_MODEL="claude-sonnet-4-6"

The Base URL has no /v1 — Claude Code appends /v1/messages itself. As an alternative to variables, use the env block in ~/.claude/settings.json or .claude/settings.local.json in the project root.

Check: claude with a one-word reply, or run /status inside the session: the Anthropic base URL line should show kiree.net.

Diagnostics

Common errors

!

401 / authentication_error

The key is missing or ANTHROPIC_API_KEY is not empty: the CLI went to Anthropic servers. Check both variables.

!

403 / 451

The request goes straight to Anthropic instead of the gateway: check ANTHROPIC_BASE_URL and that the shell profile was re-read (source ~/.bashrc).

!

429 / insufficient_quota

Balance or request quota is exhausted: top up in the console and retry after a minute.

FAQ

Frequently asked questions

How do I connect Claude Code through the gateway?+

Requests go to the kiree.net gateway directly.

Do I need an Anthropic subscription or foreign card?+

No. Usage is billed by tokens from the kiree.net balance; no Anthropic subscription is required.

Why must ANTHROPIC_API_KEY be empty?+

If the variable is unset, Claude Code tries to authenticate on Anthropic servers. An empty string disables that, and the token is passed via ANTHROPIC_AUTH_TOKEN.

Which models are available in Claude Code through kiree?+

All claude-* models from the catalog: Sonnet, Opus, Haiku. The default is set by ANTHROPIC_MODEL, e.g. claude-sonnet-4-6.

How is the cost calculated?+

Per request tokens, as in the original API: the price per 1M input and output tokens is on each model card. Charges come from the shared balance.

Get a key for Claude Code

Create a key in a couple of minutes; pay only for actual usage, no subscription required.