fix: force HTTPS for image downloads and add base64 response format#94
Open
nguyenngothuong wants to merge 1 commit intoMiniMax-AI:mainfrom
Open
fix: force HTTPS for image downloads and add base64 response format#94nguyenngothuong wants to merge 1 commit intoMiniMax-AI:mainfrom
nguyenngothuong wants to merge 1 commit intoMiniMax-AI:mainfrom
Conversation
- Auto-convert HTTP to HTTPS in downloadFile() to work around Alibaba Cloud OSS CDN blocking HTTP traffic from certain regions - Add --response-format <url|base64> flag for image generation - Add retry logic (3 attempts, exponential backoff) for download failures - Fixes image download failures with 'Network request failed' error Related: MiniMax API returns http:// URLs but OSS CDN requires https://
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.
Problem
The
mmx image generatecommand fails withNetwork request failedwhen trying to download generated images from certain regions (confirmed from Vietnam, likely affects others).Root Cause
The MiniMax Image Generation API returns image URLs using HTTP (e.g.
http://hailuo-image-*.oss-us-east-1.aliyuncs.com/...), but the Alibaba Cloud OSS US East CDN blocks HTTP traffic, causingfetch()to fail.Solution
1. Force HTTPS in
download.tsAuto-convert
http://→https://before fetching, with retry logic (3 attempts, exponential backoff).2. Add
--response-format base64flagThe API supports
response_format: base64which returns base64-encoded images directly, completely bypassing the CDN download step. This is useful as a fallback when CDN URLs are unreachable.Changes
src/files/download.tssrc/commands/image/generate.tssrc/types/api.tsresponse_formatandimage_base64typesTest Results
Related