Skip to content

Commit c2d3218

Browse files
cjfitjohntmyers
authored andcommitted
docs(providers): document subscription env preset, billing banner, and recovery
Describe the ANTHROPIC_AUTH_TOKEN env preset and why an API key is not injected, note that the API-usage billing banner in Claude Code is cosmetic while billing goes to the subscription, and add recovery steps for a rejected refresh token. Update the gateway architecture doc to match the env projection behavior. Signed-off-by: Cedric Fitzgerald <soulcedric2@gmail.com>
1 parent f41ffdc commit c2d3218

2 files changed

Lines changed: 28 additions & 17 deletions

File tree

architecture/gateway.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,10 +459,19 @@ The CLI `--from-claude-login` harvests the local Claude Code login (macOS
459459
Keychain `Claude Code-credentials` or `~/.claude/.credentials.json`) on the host,
460460
stores the access token under the non-injectable `ANTHROPIC_OAUTH_TOKEN`
461461
credential, and calls `ConfigureProviderRefresh` with the subscription's refresh
462-
token (Anthropic public `client_id` only, no secret). The background refresh
462+
token (Anthropic public `client_id` only, no secret). With `--from-claude-login`
463+
the provider name and type default (`claude-subscription` / `anthropic-oauth`),
464+
and when no user inference route exists the CLI points the route at the new
465+
provider (best-effort, unverified). The background refresh
463466
worker rotates the access token ahead of expiry and persists Anthropic's rotated
464467
refresh token. The access token is never exported into sandbox environments; it
465468
rides the inference route bundle and is injected only at the egress boundary.
469+
Instead, the provider plugin projects `ANTHROPIC_BASE_URL=https://inference.local`
470+
and a placeholder `ANTHROPIC_AUTH_TOKEN` into bound sandboxes so agent CLIs work
471+
without manual configuration or confirmation prompts; `inference.local` replaces
472+
the placeholder auth with the real token before forwarding. The base URL is
473+
resolved to its real value in the sandbox env (agents must parse it at startup);
474+
the auth token stays an egress placeholder like any other credential.
466475

467476
## Supervisor Relay
468477

docs/providers/anthropic-subscription.mdx

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,13 @@ Use this provider when you want sandboxed agents to consume your Claude subscrip
2222
Create the provider with `--from-claude-login`:
2323

2424
```shell
25-
openshell provider create \
26-
--name claude-subscription \
27-
--type anthropic-oauth \
28-
--from-claude-login
25+
openshell provider create --from-claude-login
2926
```
3027

3128
`--from-claude-login` reads the local Claude Code login, stores the access token as the gateway-side `ANTHROPIC_OAUTH_TOKEN` credential, and configures an OAuth2 refresh-token flow using your subscription's refresh token. The gateway refreshes the access token ahead of expiry and updates running sandboxes without a restart.
3229

30+
The provider name defaults to `claude-subscription` and the type to `anthropic-oauth`; pass `--name` or `--type` to override. When no inference route is configured yet, the command also points the user-facing route at the new provider with a default model, so no separate `inference set` step is needed.
31+
3332
The CLI reads the macOS Keychain first, then falls back to `~/.claude/.credentials.json`. If neither contains a login, the command fails and directs you to run `claude login`.
3433

3534
<Note>
@@ -46,6 +45,8 @@ The subscription OAuth token represents your whole plan, so it is shared across
4645

4746
To rotate or revoke, delete and recreate the provider, or rotate the credential through `openshell provider refresh`.
4847

48+
If the refresh token becomes invalid — you logged out of Claude Code, revoked the session, or the plan lapsed — `openshell provider refresh status` reports the failure with recovery instructions: run `claude login` on the host, then delete and recreate the provider with `--from-claude-login`.
49+
4950
## Configure Inference Routing
5051

5152
Enable provider endpoint injection so the Anthropic network endpoint is added to sandbox policies automatically:
@@ -54,7 +55,7 @@ Enable provider endpoint injection so the Anthropic network endpoint is added to
5455
openshell settings set --global --key providers_v2_enabled --value true --yes
5556
```
5657

57-
Then point `inference.local` at the provider:
58+
Provider creation with `--from-claude-login` configures the route automatically when none exists. To change the model, or when another route was already configured, set it explicitly:
5859

5960
```shell
6061
openshell inference set \
@@ -74,24 +75,25 @@ The complete setup from scratch:
7475
# 1. Enable provider endpoint injection
7576
openshell settings set --global --key providers_v2_enabled --value true --yes
7677

77-
# 2. Authenticate on the host, then create the provider
78-
claude login
79-
openshell provider create --name claude-subscription --type anthropic-oauth --from-claude-login
80-
81-
# 3. Configure inference routing
82-
openshell inference set --provider claude-subscription --model claude-sonnet-4-6
78+
# 2. Create the provider from the local Claude Code login
79+
# (also configures the inference route when none exists)
80+
openshell provider create --from-claude-login
8381

84-
# 4. Create a sandbox with the provider attached
85-
openshell sandbox create --name my-sandbox --provider claude-subscription
82+
# 3. Create a sandbox with the provider attached and launch Claude Code
83+
openshell sandbox create --provider claude-subscription -- claude
8684
```
8785

88-
Then inside the sandbox, launch Claude Code against the local endpoint:
86+
Step 3 drops you into Claude Code running inside the sandbox on your subscription. In an existing sandbox, launch it with no configuration:
8987

9088
```shell
91-
ANTHROPIC_BASE_URL="https://inference.local" ANTHROPIC_API_KEY=unused claude -p "Reply with exactly: pong"
89+
claude -p "Reply with exactly: pong"
9290
```
9391

94-
Setting `ANTHROPIC_API_KEY` to any placeholder makes Claude Code talk to the gateway endpoint directly instead of starting its own OAuth login flow inside the sandbox. The placeholder key never reaches Anthropic — `inference.local` strips it and injects the real subscription token before forwarding. Drop the `-p "…"` to launch the interactive TUI instead.
92+
Sandboxes bound to an `anthropic-oauth` provider start with `ANTHROPIC_BASE_URL=https://inference.local` and a placeholder `ANTHROPIC_AUTH_TOKEN` preset, so agent CLIs use the gateway endpoint instead of prompting for an interactive login. The auth token is used rather than `ANTHROPIC_API_KEY` because Claude Code accepts it without a confirmation prompt. The placeholder never reaches Anthropic — `inference.local` replaces caller auth with the real subscription token before forwarding. Set either variable explicitly to override the preset; tools that only read `ANTHROPIC_API_KEY` can be pointed at the gateway by setting that variable to any value. Drop the `-p "…"` to launch the interactive TUI instead.
93+
94+
<Note>
95+
Claude Code's startup banner may report API billing because it authenticates through an environment token. The label is cosmetic: the subscription token is injected at the egress boundary, outside the sandbox, so requests are billed to your subscription plan, not to metered API usage.
96+
</Note>
9597

9698
## Next Steps
9799

0 commit comments

Comments
 (0)