Skip to main content

Model Gateway — Mode E: Verified Subscriber Passthrough

Status: implemented behind two independent switches, both default OFF. No org is served until both are on. Artefacts: PRD #2644 v1.7 Slice 6 (MG-SUB.1–.25) · HLD #3692 · LLD #3698 · ADR-0021 Amendment 1 §A1 · S0 measurement docs/architecture/model-gateway-mode-e-s0.md

Mode E lets a developer point Claude Code at the Model Gateway and keep using their own Anthropic subscription. The organisation supplies no key and pays nothing for the tokens; what it gets is governance and a ledger.

This page is for the operator and the org admin. It is deliberately short on architecture and long on the two configuration lines, the error contract, and what each party can and cannot see.


1. The two switches, and why there are two​

They are not redundant and neither can substitute for the other.

SwitchOwnerWhereDefault
MODEL_GATEWAY_SUBSCRIBER_ADMISSIONthe operator of this deploymentprocess environment / ConfigMapdisabled
the org's platform-managed llm_endpoints rowthe org's L5 adminEnableSubscriptionMode RPCabsent

The first says does this build run the Mode E admission at all. The second is the tenant's own kill-switch. Collapsing them would mean a tenant's kill-switch could be defeated by a ConfigMap, or an operator's rollout gate could be defeated by a tenant.

Reading the live state. One boot line, model gateway controls wired, carries all of it:

subscriber_admission=disabled
subscriber_surface_allowlist="3 entries, 2 forwardable: POST /v1/messages, POST /v1/messages/count_tokens"
capture_policy=off
capture_never_classes=map[subscription:...]
subscription_accounts=*subscriberauth.AccountGate

subscriber_admission is printed unconditionally and in both positions: on a fleet where the variable is unset, this line is the only thing that distinguishes "the operator has not switched Mode E on" from "this build has no subscriber admission at all".

To turn the admission on:

MODEL_GATEWAY_SUBSCRIBER_ADMISSION: "enabled" # the only other legal value is "disabled"

An unrecognised value is a startup failure, deliberately: answering a typo with a default is how the typo becomes a policy, and here it would silently become disabled — a mode an org has paid for, switched on, and that quietly refuses every request.


2. What a subscriber configures (the two lines)​

The subscriber gets these from their own Model Subscriptions page, after accepting the disclosure. Nobody else ever sees the credential — not their Manager, not an operator, not a log.

export ANTHROPIC_BASE_URL="https://<model-gateway-host>"
export ANTHROPIC_CUSTOM_HEADERS="X-UpsQuad-Subscriber: uq_sub_…"

With more than one team grant, a third line selects which team the usage is attributed to:

export ANTHROPIC_CUSTOM_HEADERS="X-UpsQuad-Subscriber: uq_sub_…
X-UpsQuad-Team: <unit-id>"

X-UpsQuad-Subscriber is not an Anthropic credential. It identifies the member to their organisation's gateway and authorises exactly one thing: being identified. It cannot be used to sign in anywhere. The subscriber's actual Anthropic bearer never leaves their machine except as a byte-for-byte relay to api.anthropic.com.

ANTHROPIC_API_KEY must be unset. A shell that still exports one produces subscription_shape_invalid — the gateway refuses rather than guessing which of two credentials was meant. That refusal is visible on the subscriber's own page, which is where a misconfiguration should surface.


The subscriber accepts this, verbatim, before a credential is minted. It is reproduced here so an operator answering a question gives the same answer the screen does:

Your organisation's gateway reads each prompt and response as it passes, to apply content and PII policy. It does not store them — capture is off for Model Subscribers and cannot be turned on without your agreement. It records the model you used, how many tokens, when, and whether a request was refused. It never sees your Anthropic password, your login, your bill, or your plan. Your subscription credential passes through and is never stored or logged. You can see everything your organisation sees about you, on your own page, and you can leave at any time.

A posture-text change refuses until re-consent. When the platform publishes a new consent_version, every active registration whose stored version is older is refused subscriber_consent_required on the next request — there is no serving window. The alternative would leave traffic flowing under an agreement to text that no longer describes what happens.

Capture is off, and it cannot be switched on​

capture_policy=off and capture_never_classes on the boot line are the machine-readable form of the sentence above. Enabling capture for Mode E needs four things — the deployment flag, an L5 action, re-consent from each affected subscriber, and an audit row — and v1 has no per-subscriber consent column, so the third cannot be recorded, so capture cannot be enabled. It is stricter than MG-2b.5's on-prem default, by requirement.

Guardrail and PII inspection in flight is not capture. It happens, it is disclosed in the first sentence of the consent text, and it is the reason the text leads with "reads".


4. What each party can see​

the subscribertheir Manageran operator
requests, tokens by class, model mixyesyesaggregate
refusals and their reasonsyesyesaggregate by reason
account binding state (unbound / bound / mismatch)yesyesno
prompts and completions—nevernever
the subscription credentialonce, at mintnevernever
the subscriber's Anthropic plan, limits or bill—nevernever
money spent by the organisation₹0 — "subscription-billed"the same fixed words—

A subscriber always sees exactly what their Manager sees about them. That is MG-FE.9 and it is a requirement rather than a courtesy.

There is no money figure. A Mode E ledger row carries cost_basis = 'subscription_billed' and cost_usd IS NULL, and every surface renders the fixed words "subscription-billed — not metered to this organisation". Never $0.00: a zero is a claim that the organisation paid nothing, and the truth is that the question does not apply to it.

The claim bound (NG-7)​

Mode E governs what Claude Code sends and receives. It does not govern what Claude Code does on the developer's machine — files it reads, commands it runs, tools it invokes locally. Permitted wording: "every model call Claude Code makes through the gateway is governed and recorded". Not permitted: any form of "we govern Claude Code".

What the account binding detects (MG-SUB.10)​

metadata.user_id is client-supplied and unsigned. The binding detects accident and casual sharing — a pasted config line, a laptop with a former teammate's credential — reliably, because neither changes what the CLI sends. It does not detect a determined party. The column is named observed_account_uuid so nothing in the schema reads as a verified fact, and tenant-facing copy must not say the binding "verifies" anything.


5. The error contract​

Every row below is credential_class='subscription', cost_basis='subscription_billed', cost_usd NULL. A refused subscription call is "refused — not metered to this organisation", never $0.00.

ReasonHTTPStepLedger rowWhat to do
subscription_mode_disabled4033/identity or 5/routingonly when the org is knownthe org has not enabled Model Subscriptions, or an L5 disabled it. Ask the org admin.
subscriber_identity_invalid4013/identityno (no org to attribute to)the header matched no registration. Register on the portal.
subscriber_identity_expired4013/identityyesrotate the credential on the Model Subscriptions page.
subscriber_revoked4033/identityyesaccess is over. Ask the Manager.
subscriber_suspended4033/identityyesa Manager paused it; one click reinstates.
subscriber_consent_required4033/identityyesaccept the current disclosure on the page.
ambiguous_caller_identity4013/identityyesa platform credential arrived beside the header. Remove one.
subscription_shape_invalid4013/identityyesunset the Anthropic API-key variable in the shell.
subscriber_team_not_granted4033/identityyesX-UpsQuad-Team names a team this subscription is not granted; check the value or remove the header.
surface_not_allowed4045/surfaceyesthe path is not one Mode E relays. The message lists the ones it does.
subscriber_account_unreadable4005/accountyesthe request carried no readable Anthropic account id.
subscriber_account_mismatch4035/accountyesthe credential is bound to a different Claude account. Re-bind on the Model Subscriptions page.
every existing gate 4–7e reasonexistingexistingyesunchanged.
Anthropic's own 401 / 429 / 5xxupstream's—allow rowpassed through verbatim (MG-SUB.19).

Two of these are worth an operator's attention:

  • subscriber_identity_invalid and subscriber_identity_expired share the status 401 by design. A status-only probe must not be able to tell a genuine expired credential from an unregistered one. The distinguishing field is error.type in the body, which the legitimate holder reads.
  • An Anthropic 401 is relayed unchanged and marks nothing. We do not validate, refresh, interpret or retry a subscription authentication failure, and we never substitute our own error. A developer whose subscription lapsed must see Anthropic's answer, because ours would be a guess about a subscription we cannot see. A persistent 401 pattern may be surfaced to the subscriber as information, never as a governance state.

The allowed surfaces​

subscriber_surface_allowlist on the boot line is the live answer. As measured by the S0 spike against claude-cli 2.1.284:

Method + pathDispositionCarries an account id
POST /v1/messagesforwardedyes
POST /v1/messages/count_tokensforwardedno (0 of 16 recorded bodies carried metadata)
HEAD /api/helloanswered by the edge's 404 sealno

GET /v1/models is deliberately absent: claude-cli 2.1.284 never requested it in any arm, including with the /model picker open. Re-measure on a CLI upgrade before adding it.


6. Diagnosing a refusal​

  1. Read the boot line first. subscriber_admission=disabled explains every subscription_mode_disabled in one word, and no amount of registry inspection will add to that.
  2. Then ask whether the ORG is enabled. subscription_mode_disabled at gate 5/routing (rather than 3/identity) means the admission ran, the subscriber resolved, and the org has no live platform-managed endpoint row — an L5 either never ran EnableSubscriptionMode or has run DisableSubscriptionMode.
  3. deciding_gate on the ledger row says which control refused. 3/identity is about the registration; 5/surface and 5/account are about the request; 7a–7e are the ordinary gate chain and behave exactly as they do for every other caller.
  4. model_gateway_subscriber_refusals_total{org_id,reason} carries the whole closed reason vocabulary, pre-created at zero on first sight of an org — so a quiet org and an unwired build are distinguishable, and an alert over the series can fire.
  5. model_gateway_subscriber_account_events_total{org_id,event} counts bound and mismatch. A mismatch is the one worth paging a Manager about. A subscriber's own re-bind is NOT counted — it is visible in the audit trail (llm_subscriber_account_rebound) and in the row's cleared account_state, so it is uncounted rather than unobservable. #3744 adds the rebound series; until it lands, do not look for one.

Label values are reason codes and ids only — never a header, a bearer, an e-mail or an account uuid.


7. Failure modes and what the gateway does​

FailureBehaviour
Postgres unreachable at the subscriber lookup503, no cached verdict, no upstream dial
Postgres unreachable at the account bind503 governance_backend_unavailable at 5/account
Redis unreachablethe existing step-4 / 7d posture, unchanged
guardrail or PII backend unreachabledeny, retryable (MG-NFR.3)
Anthropic 401 / 429 / 5xxrelayed verbatim; the registration is not marked
the org's mode disabled mid-flightthe in-flight request completes; the next is refused
the member is offboardedthe cascade revokes every registration and grant; the next request is 403
a stolen header, before any bindthe thief's account binds, and the member sees the bind audit row

The last one is the binding's whole value: first-use is a tell-off-first event delivered to the member's own audit feed, with the observed account and the time.


8. Things an operator must not do​

  • Do not add an edge route for HEAD /api/hello. S0 ran a controlled comparison and measured the CLI tolerant of the sealed 404 — identical request multisets, no retries, no diagnostics. A route would be a second surface on a sealed hostname with no measured need, and TestSurfaceEdge_EdgeAnsweredEntriesAgreeWithTheEdge fails on it.
  • Do not point a caller_subscription endpoint row anywhere but https://api.anthropic.com. Three independent controls refuse it (a database CHECK, the dial guard, and a per-request target assertion), so the attempt fails rather than leaks — but it fails as an outage for that org.
  • Do not give the Model Gateway process an Anthropic key for Mode E. The vault is not read on this path at all. A key configured "to be safe" would be a second credential on a request whose entire contract is that nothing of the organisation's rides it.
  • Do not enable capture for the subscription class. It is refused by construction; the point of this line is that an attempt will look like a configuration that silently did nothing.