just one network call to api.anthropic.com/api/oauth/usage using the local OAuth token, and nothing else for Anthropic.
This commit is contained in:
parent
6bd6390b47
commit
56df59ff86
|
|
@ -1023,10 +1023,23 @@ async def _do_fetch_provider_usage(
|
||||||
error="No API key configured.",
|
error="No API key configured.",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
elif local_oauth:
|
||||||
|
# Local Claude session is the primary source — use the subscription
|
||||||
|
# endpoint only. Skipping /v1/models eliminates the sequential
|
||||||
|
# same-IP request that caused the subscription endpoint to 429.
|
||||||
|
subscription_attempted = True
|
||||||
|
result = ProviderUsageLive(
|
||||||
|
provider=provider, account_key=account_key,
|
||||||
|
checked_at=utcnow(), reachable=True,
|
||||||
|
)
|
||||||
|
sub_windows = await _fetch_anthropic_subscription(local_oauth)
|
||||||
|
if sub_windows:
|
||||||
|
result.subscription_windows = sub_windows
|
||||||
|
else:
|
||||||
|
result.error = "No subscription data returned."
|
||||||
|
|
||||||
elif api_key and effective_session_key:
|
elif api_key and effective_session_key:
|
||||||
# Fire both calls concurrently — halves latency and eliminates the
|
# No local OAuth — fire API key + session key calls concurrently.
|
||||||
# sequential back-to-back requests to api.anthropic.com that caused
|
|
||||||
# the subscription endpoint to 429 on every initial load.
|
|
||||||
subscription_attempted = True
|
subscription_attempted = True
|
||||||
result, sub_windows = await asyncio.gather(
|
result, sub_windows = await asyncio.gather(
|
||||||
_fetch_anthropic(api_key, base_url),
|
_fetch_anthropic(api_key, base_url),
|
||||||
|
|
@ -1043,7 +1056,7 @@ async def _do_fetch_provider_usage(
|
||||||
result = await _fetch_anthropic(api_key, base_url)
|
result = await _fetch_anthropic(api_key, base_url)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# OAuth token only — no API key configured
|
# session_key only, no local OAuth, no API key
|
||||||
subscription_attempted = True
|
subscription_attempted = True
|
||||||
result = ProviderUsageLive(
|
result = ProviderUsageLive(
|
||||||
provider=provider, account_key=account_key,
|
provider=provider, account_key=account_key,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue