Skip to content

Conversation

@apoorvdarshan
Copy link
Contributor

Global region users with API keys (sk-cp-...) were getting "credentials invalid" errors because the fetcher used a hardcoded China endpoint.

image
  • Add apiBaseURLString and apiRemainsURL to MiniMaxAPIRegion for region-specific API hosts (api.minimax.io vs api.minimaxi.com)
  • Update fetchUsage(apiToken:) to accept region parameter
  • Pass region from settings through MiniMaxAPIFetchStrategy
  • Make API region picker always visible in settings UI

Fixes #276

Image

on minimax official website (for confirmation)
Image

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 24ffd12ff9

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@apoorvdarshan apoorvdarshan force-pushed the fix/minimax-global-region branch from 24ffd12 to b60a078 Compare January 30, 2026 23:00
@apoorvdarshan
Copy link
Contributor Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b60a078708

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Global region users with API keys (sk-cp-...) were getting "credentials
invalid" errors because the fetcher used a hardcoded China endpoint.

- Add apiBaseURLString and apiRemainsURL to MiniMaxAPIRegion for
  region-specific API hosts (api.minimax.io vs api.minimaxi.com)
- Update fetchUsage(apiToken:) to accept region parameter
- Pass region from settings through MiniMaxAPIFetchStrategy
- Make API region picker always visible in settings UI
- Default to global when settings are absent (CLI/library contexts)

Fixes steipete#276
@apoorvdarshan apoorvdarshan force-pushed the fix/minimax-global-region branch from b60a078 to 726ffb0 Compare January 30, 2026 23:09
@ratulsarna
Copy link
Collaborator

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 726ffb0d57

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

throw MiniMaxAPISettingsError.missingToken
}
let usage = try await MiniMaxUsageFetcher.fetchUsage(apiToken: apiToken)
let region = context.settings?.minimax?.apiRegion ?? .global

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve legacy endpoint when MiniMax region is unset

Defaulting apiRegion to .global here changes behavior for existing API-token users who never had a region saved: before this commit, API usage always hit api.minimaxi.com, but now it hits api.minimax.io unless the user manually updates settings. Because the region picker was previously hidden in API-token mode, many China-mainland users will have no persisted region and can regress from working to invalidCredentials immediately after upgrade. Consider keeping backward-compatible defaulting (or inferring region from existing token/config) when apiRegion is absent.

Useful? React with 👍 / 👎.

ratulsarna added a commit that referenced this pull request Feb 10, 2026
When fetching with an API token and region defaults to .global, retry the China mainland API host if the global host rejects the token. This preserves upgrade behavior for users who previously depended on the China endpoint by default.

Credit: @apoorvdarshan (PR #277, issue #276 investigation).
When the global host (api.minimax.io) returns 401/403, retry with the
China mainland host (api.minimaxi.com) to mitigate upgrade regression
for existing CN users with no persisted region.

If the China retry also fails (e.g. DNS failure, transport error),
rethrow the original invalidCredentials error so that
shouldFallback still recognises it and falls back to web scraping.
@apoorvdarshan
Copy link
Contributor Author

since another PR #344 is created for this, hence by closing this PR #277

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.

can't fetch minimax usage

2 participants