Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix: proxied usage limits follow the hub's model routing and show on the thread card #30778

MergedBil0000(GitHub profile, opens in a new tab)merged 38 commits intomain fromrefs/pull/30778/headmerged by juliusmarminge View on GitHub

Bil0000(GitHub profile, opens in a new tab)commented

Problem

When a provider sends its requests through a CLIProxyAPI hub (for example Claude Code with ANTHROPIC_BASE_URL pointed at the hub), the instance can't read limits of its own. The thread details card showed Limits: Unavailable, even though the Usage page showed the hub's accounts. The hub reset fallback for usage-limit stops (#36238) also matched hub accounts by provider only. Two cases broke it:

  • A hub can route a model to accounts of another provider, or keep some accounts off a model. One account that never serves the model, but still has room, blocked the reset.
  • Antigravity meters Gemini apart from Claude/GPT. A spent Gemini window blocked the reset for Claude and GPT turns on the same account.

Fix

  • Model routing. The server reads each hub account's routed models from auth-files/models. That read runs alongside the usage read and is capped at 2s, so it can't hold up a refresh. The reset fallback, the thread card and /usage-limits count only the accounts that serve the thread's model.
    • A thinking suffix such as gpt-5.2(high) routes by its base model, as the hub does.
    • Older hubs without that endpoint, and aliases no account lists (such as opus), fall back to matching by provider.
    • An account whose model list couldn't be read still counts for its own provider.
  • Antigravity. Each quota only limits the models it meters: Gemini Argon, Gemini Carbon, other Gemini models, and the shared Claude/GPT quota. This applies to both the reset fallback and the card.
    • Hub prefixes such as ag/ are ignored when deciding which family a model belongs to.
    • An alias of unknown family counts both quotas.
  • Thread card and /usage-limits. An instance whose endpoint is the hub's address shows the pool the hub routes its model to: remaining %, pace, the next refill and its source.
    • Reset credits are only offered from that instance's own hubs.
    • Logins that don't go through a hub behave as before.

The hub counts as an instance's hub only when its configured origin exactly equals the instance's endpoint origin. That is the same rule #36238 uses, and the user docs now say so.

Before / after

Claude Code through a hub, thread details card:

Before (main)After

Checked live against a real CLIProxyAPI hub with 7 Claude accounts, plus Codex, Antigravity and xAI accounts. With Opus 5.5 selected, the card's Session, Weekly and Weekly · Fable rows match the Claude pool on the Usage page. The tooltip shows "+14% in 2d 3h" for the next refill.

Tests

  • A Claude Code turn recorded through a real CLIProxyAPI hub, which forwarded the upstream 429 without its reset headers, replays as usage_limit. With the instance at the hub's endpoint, the reset is the refill of the account that serves the turn's model. An account with room that doesn't serve the model does not block it. This fails on main.
  • Rows in the existing hubPoolResetAt, cliproxyApi and usageLimits tests cover cross-provider routing, the alias fallback, Antigravity, and older hubs.
  • vp run check:changed passes. One unrelated ChatView browser test timed out under load and passes on its own.

Originally by @Bil0000; thank you! Maintainer takeover:

  • Merged main and localized the new card rows.
  • Fixes from review:
    • The card splits Antigravity quotas.
    • The model lookup can't hold back a quota refresh.
    • A lent last-good reading keeps fresh routes.
    • Suffix, prefix and alias handling.
    • Reset credits stay on the thread's hub.
    • Hub accounts stay visible for logins that don't go through a hub.

Created by Claude Opus 5.5 in Claude Code (T3 Code); reviewed by Claude Opus 5.5 and GPT 6.2 Sol.

🤖 Generated with Claude Code

    1. Pushedab2f5a6

    2. Pushed3491e39

    3. Pushede8eea76

    4. juliusmarminge merged thisc436409

    5. juliusmarminge closed this

Sign in to join this conversation.