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.
Pick either mode, or run both: each request picks the right one, and both get usage tracking and token savings.
| 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 |
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:
npx anyray-connect@latest
Add --subscription to force it for every tool. Either way, each developer needs their own
gateway key (ark_…, from --enroll or --sso; see client keys).
Anyray sends the request to Anthropic with your own token and Claude Code's original shape, no shared key involved. 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-code-*,
x-claude-remote-*, 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, with 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.
One rate limit is never absorbed. When Anthropic refuses an over-200k request from a seat that has no long-context usage credits, Claude Code reads that refusal to drop its own context window back to 200k. The gateway surfaces it verbatim rather than overflowing, so the client corrects itself instead of continuing to send a context the seat cannot afford.