-
Notifications
You must be signed in to change notification settings - Fork 350
fix: use region-specific API endpoint for MiniMax usage fetch #277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: use region-specific API endpoint for MiniMax usage fetch #277
Conversation
There was a problem hiding this 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".
24ffd12 to
b60a078
Compare
|
@codex review |
There was a problem hiding this 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".
Sources/CodexBarCore/Providers/MiniMax/MiniMaxProviderDescriptor.swift
Outdated
Show resolved
Hide resolved
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
b60a078 to
726ffb0
Compare
|
@codex review |
There was a problem hiding this 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 👍 / 👎.
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.
Global region users with API keys (sk-cp-...) were getting "credentials invalid" errors because the fetcher used a hardcoded China endpoint.
Fixes #276
on minimax official website (for confirmation)
