feat: dynamic API endpoint resolution and DashScope headers support (v1.4.0)#7
Open
ishan-parihar wants to merge 2 commits intogustavodiasdev:mainfrom
Open
feat: dynamic API endpoint resolution and DashScope headers support (v1.4.0)#7ishan-parihar wants to merge 2 commits intogustavodiasdev:mainfrom
ishan-parihar wants to merge 2 commits intogustavodiasdev:mainfrom
Conversation
added 2 commits
February 28, 2026 03:30
…v1.4.0) - Add resolveBaseUrl() to dynamically select API endpoint based on resource_url - Support portal.qwen.ai, dashscope, and dashscope-intl endpoints - Add DashScope-specific headers (X-DashScope-CacheControl, X-DashScope-UserAgent, X-DashScope-AuthType) - Fix loader return format (baseURL instead of baseUrl) to fix ERR_INVALID_URL error - Add loadCredentials() to read resource_url from credentials file - Add chat.headers hook for injecting DashScope headers - Update README with multi-endpoint documentation - Bump version to 1.4.0 Fixes: - ERR_INVALID_URL: "undefined/chat/completions" cannot be parsed as a URL - "Incorrect API key provided" when using portal.qwen.ai tokens with DashScope URL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds dynamic API endpoint resolution and DashScope headers support to fix compatibility issues with different Qwen OAuth token regions.
Changes
New Features
Dynamic API Endpoint Resolution: Automatically detects and uses the correct API endpoint based on
resource_urlfrom the OAuth tokenportal.qwen.ai→https://portal.qwen.ai/v1dashscope→https://dashscope.aliyuncs.com/compatible-mode/v1dashscope-intl→https://dashscope-intl.aliyuncs.com/compatible-mode/v1DashScope Headers Support: Automatically injects required headers when using DashScope endpoints:
X-DashScope-CacheControl: enableX-DashScope-UserAgentX-DashScope-AuthType: qwen-oauthBug Fixes
ERR_INVALID_URLerror: The loader now returnsbaseURL(capital letters) instead ofbaseUrl, which OpenCode expectsportal.qwen.aitokens were being routed to DashScope URL, causing authentication failuresTechnical Details
loadCredentials()function to readresource_urlfrom credentials fileresolveBaseUrl()function for URL resolution logicchat.headershook for injecting DashScope-specific headersbaseURLfrom config hook (now set dynamically by loader)Testing
Tested with:
portal.qwen.aitoken (international users)Files Changed
src/constants.ts- Added DashScope headers constant and multiple base URLssrc/plugin/auth.ts- AddedloadCredentials()andresolveBaseUrl()functionssrc/index.ts- Dynamic URL resolution, headers hook, fixed loader return formatpackage.json- Version bump to 1.4.0README.md- Updated documentation with new features