You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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>
Copy file name to clipboardExpand all lines: docs/providers/anthropic-subscription.mdx
+18-16Lines changed: 18 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,14 +22,13 @@ Use this provider when you want sandboxed agents to consume your Claude subscrip
22
22
Create the provider with `--from-claude-login`:
23
23
24
24
```shell
25
-
openshell provider create \
26
-
--name claude-subscription \
27
-
--type anthropic-oauth \
28
-
--from-claude-login
25
+
openshell provider create --from-claude-login
29
26
```
30
27
31
28
`--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.
32
29
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
+
33
32
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`.
34
33
35
34
<Note>
@@ -46,6 +45,8 @@ The subscription OAuth token represents your whole plan, so it is shared across
46
45
47
46
To rotate or revoke, delete and recreate the provider, or rotate the credential through `openshell provider refresh`.
48
47
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
+
49
50
## Configure Inference Routing
50
51
51
52
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
54
55
openshell settings set --global --key providers_v2_enabled --value true --yes
55
56
```
56
57
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:
58
59
59
60
```shell
60
61
openshell inference set \
@@ -74,24 +75,25 @@ The complete setup from scratch:
74
75
# 1. Enable provider endpoint injection
75
76
openshell settings set --global --key providers_v2_enabled --value true --yes
76
77
77
-
# 2. Authenticate on the host, then create the provider
#3. Create a sandbox with the provider attached and launch Claude Code
83
+
openshell sandbox create --provider claude-subscription -- claude
86
84
```
87
85
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:
89
87
90
88
```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"
92
90
```
93
91
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.
0 commit comments