Skip to main content

Anthropic

Point Claude Code and the Anthropic SDKs at the gateway. Anyray works with your team's own Claude subscriptions, a shared API key, or both at once.

Two ways to run Claude

Pick either — or use both. Each request picks the right one, and both get usage tracking and token savings.

Anthropic details

PropertyValue
Provider idanthropic
Gateway speaksMessages API → api.anthropic.com/v1/messages
CredentialShared API key, or the developer's own login
Client base URLANTHROPIC_BASE_URLhttp://<gateway>:8787

Shared setup — self-hosting, the redirect, credential storage — lives in the gateway.

API key

Point your client at the gateway; Anyray uses a shared key.

export ANTHROPIC_BASE_URL=http://<gateway>:8787

Add the key in Console → Providers → anthropic (or set ANYRAY_PROVIDER_KEY_ANTHROPIC). This mode supports routing, fallbacks, and load-balancing across your Claude traffic.

Subscription login

A developer signed into a Claude plan (Claude Code on Claude / Max) keeps their own login. Plain Connect sets it up for you:

npx anyray-connect

Add --subscription to force it for every tool. Either way, each developer needs their own gateway key (ark_…, from --enroll or --sso).

Anyray sends the request to Anthropic with your own token and Claude Code's original shape — no shared key needed. Requests are still tracked and optimized, but this mode skips routing and fallbacks (it rides your subscription token).

Why the request keeps Claude Code's exact shape

Anthropic throttles a subscription token if the request doesn't look like real Claude Code. So pass-through (marked x-anyray-auth-mode: passthrough) keeps the client's own headers (user-agent, anthropic-*, x-anthropic-*, x-app*, x-claude-*, x-cc-*, x-client-*, x-stainless-*) and strips edge headers (ALB, Railway, Cloudflare, service mesh). Anthropic sees Claude Code, not Anyray. The token is never logged or stored, and Anyray still compresses the request body for token savings. A custom x-anyray-custom-host keeps its own headers for corporate proxies.

How rate limits (429s) are handled

On a 429, the gateway pauses that seat's Claude requests. Short waits are handled server-side; longer ones come back as 429 with Retry-After. Tune the max wait with ANYRAY_ANTHROPIC_THROTTLE_WAIT_MS (60000 ms default; 0 to never wait).

Seat overflow (optional)

Off by default. When a seat runs out of subscription capacity, the gateway can retry on the org's Anthropic API key so work keeps flowing. Those retries bill as subscription-extra and are capped per hour. To turn on:

  1. Store an org Anthropic API key (Console, or PUT /admin/provider-keys).
  2. PUT /admin/settings with {"seatOverflow": true} (optional "seatOverflowHourlyMaxRequests", default 60). Send {"seatOverflow": false} to turn it off — no redeploy.

Overflow only ever goes to api.anthropic.com — requests sent to a custom host (x-anyray-custom-host) never use the org key.