Skip to content

Routines bill metered API credits instead of the subscription when ANTHROPIC_API_KEY is set in the cloud environment (subscription headroom remained; $1,122.83 over two months) #86723

Description

@rasterfactory

Routines billed to metered API credits instead of the Max subscription, while subscription headroom remained

Summary

Scheduled Routines created and owned under a Max 20x subscription ($200/mo) were billed entirely to
pay-as-you-go API credits rather than drawing down subscription usage, while substantial
subscription headroom remained
(interactive usage never approached plan limits in this period).
Over two months this amounted to $1,122.83 in metered API charges: $821.39 (June 2026) and
$301.44 (July 1–17, 2026), drawn via repeated ~$45 auto-reload credit grants.

The apparent cause is an ANTHROPIC_API_KEY present in the cloud environment attached to the
routine. Nothing in the Routines UI, the run history, or the Routines documentation indicates that an
environment variable can silently redirect a routine's billing off the subscription and onto metered
API credits.

Expected behavior

Per Routines → Usage and limits:

"Routines draw down subscription usage the same way interactive sessions do."

The same page documents metered billing only as an overage path, conditional on first exhausting the
plan:

"When a routine hits the daily cap or your subscription usage limit, organizations with usage
credits turned on can keep running routines on metered overage."

With subscription headroom remaining, neither condition was met, so runs should have drawn down
subscription usage.

Actual behavior

Every routine run was billed as metered API usage from the first run onward — not after any cap was
reached. The Console Cost dashboard shows continuous near-daily spend tracking the routine's
schedule (every 3 hours, ~8 runs/day), across Opus and Sonnet, including ~6,290 web searches in June
alone. Subscription usage was not exhausted at any point.

Environment

  • Plan: Max 20x (claude.ai subscription)
  • Routine created from the Claude Code macOS Desktop app (Cloud routine), schedule trigger every 3 hours
  • Cloud environment: custom environment with environment variables set for the repository's own tooling
  • Among those variables: ANTHROPIC_API_KEY (present for unrelated reasons — a fenced build-time
    script and Cloudflare Worker secrets; not needed by the routine's own work)

Suspected mechanism

Two separate layers appear to be involved, and only the first is documented:

  1. Routine creation/ownership requires a claude.ai login. This is documented, and /schedule is
    correctly unavailable when an API key is the active local credential.
  2. The cloud session that executes the run inherits the cloud environment's variables. Per
    Authentication, ANTHROPIC_API_KEY sits above
    subscription OAuth in Claude Code's credential precedence. So a key injected as a cloud environment
    variable appears to be picked up by the Claude Code process inside the run and to take precedence
    over the subscription that owns the routine.

If that is what is happening, the routine is owned by a subscription but executed against API billing,
with no surface anywhere that reflects the split.

Why this is hard to notice

  • The Routines documentation discusses environment variables only as a capability and
    secrets-exposure concern, never as something that can change billing.
  • The routine's run history shows successful runs with no indication of billing source.
  • claude.ai subscription usage and Console API spend are separate dashboards; nothing correlates a
    routine run to the API charge it produced.
  • Console spend-threshold alerts do fire, but they report only that a dollar threshold was crossed —
    not which product consumed it, and not that a subscription-owned routine was the consumer. In this
    case they arrived well after the majority of the spend.
  • Auto-reload silently funds the resulting consumption in ~$45 increments.

Suggested fixes (any one would have prevented this)

  1. Ignore ANTHROPIC_API_KEY from cloud environment variables for routine execution, or require
    an explicit opt-in, since routines are inherently subscription-owned.
  2. Warn at routine creation/edit time when the selected cloud environment defines
    ANTHROPIC_API_KEY / ANTHROPIC_AUTH_TOKEN, stating plainly that runs will bill metered API
    credits rather than the subscription.
  3. Show the billing source on the routine detail page and on each run ("this run drew down
    subscription usage" vs "this run billed API credits").
  4. Document the precedence interaction in Routines → Usage and limits — currently the only
    metered path described is overage after plan exhaustion.

Impact

$1,122.83 over two months on an account already paying $200/month for the plan the work was intended
to run on, with no in-product signal that the two had become decoupled.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:autharea:costarea:routinesClaude Code routines on web, used for scheduled tasks, webhook-triggered tasks, etc.bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions