Summary
When a jcode SDK session starts with an Anthropic OAuth token
(sk-ant-oat01-…, the kind minted by a Claude subscription sign-in) whose scopes
allow inference but NOT the usage endpoint, the SDK treats its startup usage
preflight as fatal and the session dies before the first message is ever sent to
the model.
What happens
- The SDK session starts normally.
- Because the credential is an OAuth token, the SDK runs its OAuth preflight:
GET /api/oauth/usage plus GET /v1/models.
- Observed statuses from Anthropic:
GET /v1/models → 200 — the token is valid for inference
GET /api/oauth/usage → 403
- ~1.7s after session start, the session terminates.
- No
/v1/messages call is ever attempted.
Expected behavior
A 403 from the usage endpoint is a cosmetic/quota-display concern. With
/v1/models returning 200 for the same credential, the SDK should log and skip
the failed preflight (degrade gracefully) and proceed to inference. A usage/quota
readout can show "unavailable" instead of tearing down the session.
Actual behavior
The failed usage preflight is treated as terminal: the session closes before any
inference call, so a credential fully capable of chat completions cannot be used
through the SDK at all.
Repro
- Obtain an Anthropic OAuth token (
sk-ant-oat01-…) that can call /v1/messages
/ /v1/models but 403s on /api/oauth/usage.
- Start a session through the jcode SDK with that credential.
- Observe the session terminate immediately after the preflight, with no message
call attempted.
Notes
- Workaround: use a standard API key (
sk-ant-api…) instead of the OAuth token.
- Observed from outside the SDK, so internal naming of the preflight may differ.
Summary
When a jcode SDK session starts with an Anthropic OAuth token
(
sk-ant-oat01-…, the kind minted by a Claude subscription sign-in) whose scopesallow inference but NOT the usage endpoint, the SDK treats its startup usage
preflight as fatal and the session dies before the first message is ever sent to
the model.
What happens
GET /api/oauth/usageplusGET /v1/models.GET /v1/models→ 200 — the token is valid for inferenceGET /api/oauth/usage→ 403/v1/messagescall is ever attempted.Expected behavior
A 403 from the usage endpoint is a cosmetic/quota-display concern. With
/v1/modelsreturning 200 for the same credential, the SDK should log and skipthe failed preflight (degrade gracefully) and proceed to inference. A usage/quota
readout can show "unavailable" instead of tearing down the session.
Actual behavior
The failed usage preflight is treated as terminal: the session closes before any
inference call, so a credential fully capable of chat completions cannot be used
through the SDK at all.
Repro
sk-ant-oat01-…) that can call/v1/messages/
/v1/modelsbut 403s on/api/oauth/usage.call attempted.
Notes
sk-ant-api…) instead of the OAuth token.