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.
Anyray holds one Anthropic API key and uses it for your whole team. Adds routing and fallbacks.
Subscription loginEach developer keeps their own Claude plan (Claude Code / Max). Anyray passes their login straight through — no shared key needed.
Anthropic details
| Property | Value |
|---|---|
| Provider id | anthropic |
| Gateway speaks | Messages API → api.anthropic.com/v1/messages |
| Credential | Shared API key, or the developer's own login |
| Client base URL | ANTHROPIC_BASE_URL → http://<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:
- Store an org Anthropic API key (Console, or
PUT /admin/provider-keys). PUT /admin/settingswith{"seatOverflow": true}(optional"seatOverflowHourlyMaxRequests", default60). 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.