Skip to content

fix: force HTTPS for image downloads and add base64 response format#94

Merged
RyanLee-Dev merged 1 commit intoMiniMax-AI:mainfrom
nguyenngothuong:fix/image-download-https
Apr 24, 2026
Merged

fix: force HTTPS for image downloads and add base64 response format#94
RyanLee-Dev merged 1 commit intoMiniMax-AI:mainfrom
nguyenngothuong:fix/image-download-https

Conversation

@nguyenngothuong
Copy link
Copy Markdown
Contributor

Problem

The mmx image generate command fails with Network request failed when 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, causing fetch() to fail.

❌ http://hailuo-image-*.oss-us-east-1.aliyuncs.com/... → "fetch failed"
✅ https://hailuo-image-*.oss-us-east-1.aliyuncs.com/... → 200 OK

Solution

1. Force HTTPS in download.ts

Auto-convert http://https:// before fetching, with retry logic (3 attempts, exponential backoff).

2. Add --response-format base64 flag

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.

Changes

File Description
src/files/download.ts Force HTTPS conversion + retry logic
src/commands/image/generate.ts Add `--response-format <url
src/types/api.ts Add response_format and image_base64 types

Test Results

# Default mode (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)

Related

- 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://
@RyanLee-Dev
Copy link
Copy Markdown
Collaborator

pls solve conflicts

@draix
Copy link
Copy Markdown

draix commented Apr 24, 2026

Hi @nguyenngothuong 👋 — hit this same bug from Uruguay (images failing to download from the OSS CDN). Your fix looks great, I read through the diff and it matches exactly what I was going to propose.

Happy to help push this over the line if you're busy: I can rebase on main and resolve the conflicts on a branch, then open a follow-up PR crediting this one — or you can add me as a collaborator on your fork and I'll push directly. Whatever works best for you.

cc @RyanLee-Dev in case this helps unblock review.

Thanks for the clean diagnosis in #93 🙌

RyanLee-Dev added a commit that referenced this pull request Apr 24, 2026
fix: resolve merge conflicts for PR #94 and complete SKILL.md docs
@RyanLee-Dev RyanLee-Dev merged commit 855ce77 into MiniMax-AI:main Apr 24, 2026
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.

3 participants