Skip to content

fix(quota): skip the xAI weekly allowance on free accounts - #172

Open
1dgar wants to merge 2 commits into
router-for-me:devfrom
Ad-Quanta:fix/xai-weekly-quota-pr
Open

1dgar wants to merge 2 commits into
router-for-me:devfrom
Ad-Quanta:fix/xai-weekly-quota-pr

Conversation

@1dgar

@1dgar 1dgar commented Oct 25, 2026 •

Copy link
Copy Markdown

Summary

  • Read the xAI subscription tier before applying weekly credits.
  • Skip the weekly allowance for free accounts.
  • Treat a missing creditUsagePercent on a weekly period as 0% usage for paid plans.
  • Derive the plan name from subscriptionTier when monthly billing does not identify one.

Problem

/v1/billing?format=credits returns a weekly period for free accounts as well as paid subscriptions. Free accounts are not entitled to that allowance, but the collector previously turned the response into an xai-weekly-usage window.

Paid accounts at 0% usage are also easy to miss. proto3 JSON omits creditUsagePercent when the value is zero, so dropping that response hides a valid weekly window.

Solution

Request /v1/user?include=subscription and branch on subscriptionTier:

  • null, an empty string, free, or none: skip weekly credits.
  • A paid tier: keep the weekly window. A missing percent is recorded as 0/100.
  • Profile request failure, or a response with no tier field: keep the previous behavior and still apply weekly credits.
  • When monthly billing does not identify a plan, use the tier name: SuperGrok, SuperGrok Plus, or SuperGrok Heavy.

The stored profile base URL stays https://cli-chat-proxy.grok.com/v1/user. include=subscription is added only when the request is sent.

Tests

  • go test ./internal/quota/...
  • CGO_ENABLED=1 go build -o test-output ./cmd/home

Free accounts report the same weekly credits period as paid plans. Read the subscription tier first, and treat a missing creditUsagePercent as zero usage.
@1dgar

1dgar commented Oct 26, 2026

Copy link
Copy Markdown
Author

Could a maintainer please approve and run the pull request workflows?
The PR is currently blocked with an action_required status.

Keep the profile URL query-free and append include=subscription when probing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant