Skip to content

Conversation

@Bittabola
Copy link

Summary

OpenCode's new OAuth integration (Jan 2026 partnership with GitHub) doesn't grant access to the internal /copilot_internal/* endpoints, causing quota queries to return 404 errors. This PR adds support for querying quota via GitHub's public billing API.

Changes

  • Add CopilotQuotaConfig type with token, username, and tier fields
  • Add CopilotTier type for subscription tiers: free, pro, pro+, business, enterprise
  • Read config from ~/.config/opencode/copilot-quota-token.json
  • Call public API: GET /users/{username}/settings/billing/premium_request/usage
  • Format response with progress bar, model breakdown, and billing period
  • Fall back to internal API for legacy tokens (backward compatible)
  • Add helpful setup instructions in error messages (English & Chinese)

Tier Limits

Tier Monthly Premium Requests
free 50
pro 300
pro+ 1500
business 300
enterprise 1000

Setup

Users need to create a fine-grained PAT with "Plan" read permission:

  1. Visit https://github.com/settings/tokens?type=beta
  2. Create new token with "Account permissions" → "Plan" → "Read-only"
  3. Create config file ~/.config/opencode/copilot-quota-token.json:
{
  "token": "github_pat_xxx...",
  "username": "YourUsername",
  "tier": "pro"
}

Example Output

Account:        GitHub Copilot (@username)

Premium        ████████████████░░░░ 80% (60/300)

Model breakdown:
  Claude Opus 4.5: 60 requests

Period: 2026-01

…hip change

OpenCode's new OAuth integration (Jan 2026) doesn't grant access to the
internal /copilot_internal/* endpoints. This adds support for querying
quota via GitHub's public billing API using a user-configured fine-grained
PAT with 'Plan' read permission.

Changes:
- Add CopilotQuotaConfig type with token, username, and tier fields
- Add CopilotTier type for subscription tiers (free/pro/pro+/business/enterprise)
- Read config from ~/.config/opencode/copilot-quota-token.json
- Call public API: GET /users/{username}/settings/billing/premium_request/usage
- Format response with progress bar, model breakdown, and billing period
- Fall back to internal API for legacy tokens
- Add helpful setup instructions in error messages (EN/ZH)

Tier limits:
- free: 50 requests/month
- pro: 300 requests/month
- pro+: 1500 requests/month
- business: 300 requests/month
- enterprise: 1000 requests/month
@Bittabola Bittabola mentioned this pull request Jan 18, 2026
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