Problem
The mmx image generate command fails with Network request failed when trying to download generated images.
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 from many regions, causing fetch() to fail with Network request failed.
Direct test:
❌ http://hailuo-image-*.oss-us-east-1.aliyuncs.com/... → "fetch failed"
✅ https://hailuo-image-*.oss-us-east-1.aliyuncs.com/... → 200 OK, image downloaded
This affects any region where the OSS CDN blocks HTTP traffic (confirmed from Vietnam, likely affects other regions too).
Solution
Fix 1: Force HTTPS in download.ts
Auto-convert http:// → https:// before fetching:
const downloadUrl = url.startsWith('http://') ? url.replace('http://', 'https://') : url;
Fix 2: Add --response-format base64 option
The API supports response_format: base64 which returns base64-encoded images directly, completely bypassing the CDN download step. This is useful as a fallback when CDN URLs are unreachable.
Files Changed
| File |
Change |
src/files/download.ts |
Force HTTPS + retry logic (3 attempts, exponential backoff) |
src/commands/image/generate.ts |
Add `--response-format <url |
src/types/api.ts |
Add response_format to ImageRequest, image_base64 to ImageResponse |
Test Results
# Default (HTTP→HTTPS fix)
mmx image "A sunset over mountains" --out-dir ./out/
# ✅ Saved: ./out/image_001.jpg (290KB, 1024x1024 JPEG)
# Base64 mode (bypasses CDN entirely)
mmx image "A cat wearing sunglasses" --response-format base64 --out-dir ./out/
# ✅ Saved: ./out/image_001.jpg (571KB, 1024x1024 JPEG)
Both modes produce valid JPEG images successfully.
Note
This is an infrastructure-side issue (OSS CDN blocking HTTP) that the CLI can work around on the client side. The ideal long-term fix would be for MiniMax to return HTTPS URLs directly from the API.
Problem
The
mmx image generatecommand fails withNetwork request failedwhen trying to download generated images.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 from many regions, causingfetch()to fail withNetwork request failed.Direct test:
This affects any region where the OSS CDN blocks HTTP traffic (confirmed from Vietnam, likely affects other regions too).
Solution
Fix 1: Force HTTPS in download.ts
Auto-convert
http://→https://before fetching:Fix 2: Add
--response-format base64optionThe 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.Files Changed
src/files/download.tssrc/commands/image/generate.tssrc/types/api.tsresponse_formattoImageRequest,image_base64toImageResponseTest Results
Both modes produce valid JPEG images successfully.
Note
This is an infrastructure-side issue (OSS CDN blocking HTTP) that the CLI can work around on the client side. The ideal long-term fix would be for MiniMax to return HTTPS URLs directly from the API.