siyuan-note/siyuan · error

MiniMax image size must be WIDTHxHEIGHT

Error message

MiniMax image size must be WIDTHxHEIGHT

What it means

The MiniMax image transport rewrites OpenAI-style /images/generations requests into MiniMax's /image_generation API. MiniMax takes explicit width/height rather than the OpenAI "SIZE" string, so the transport parses input.Size by splitting on "x" and requires exactly two parts. Anything else (one part, three parts, empty separators) is rejected with this error.

Solutions

  1. Set input.Size to strict "WIDTHxHEIGHT" format with lowercase x, e.g. "1024x1024"
  2. Use "" or "auto" to get the default 1:1 aspect ratio instead of a keyword size
  3. Normalize the size string before the request: lowercase it and validate the WxH pattern
  4. If the value comes from user config, validate it at config-save time with a regex like ^\d+x\d+$

Example fix

// before
size := "1024X1024" // capital X -> split gives 1 part
// after
size := strings.ToLower(strings.TrimSpace(size))
if matched, _ := regexp.MatchString(`^\d+x\d+$`, size); !matched && size != "" && size != "auto" {
    size = "" // fall back to default aspect ratio
}
Defensive patterns

Strategy: validation

Validate before calling

valid, _ := regexp.MatchString(`^\d+x\d+$`, size)
if !valid && size != "" && size != "auto" { size = "" } // default 1:1

Try / catch

resp, err := client.CreateImages(ctx, req)
if err != nil {
    if strings.Contains(err.Error(), "must be WIDTHxHEIGHT") {
        req.Size = "" // fall back to default aspect ratio and retry once
        resp, err = client.CreateImages(ctx, req)
    }
    if err != nil { return err }
}

Prevention

When it happens

Trigger: Requesting an image generation against a MiniMax endpoint (api.minimax.io/.cn/api.minimaxi.com) with size set to a non "WxH" string, e.g. "1024" (no x), "1024X1024" (capital X), "1x1x1", or an OpenAI-style keyword other than "auto" like "large".

Common situations: Reusing OpenAI DALL-E size keywords or configs copied from an OpenAI provider where sizes like "1024x1024, 1792x1024" are valid; case-sensitive "X" separator typo; plugin passing a free-form size label.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/d4b11384a571a001. Report an issue: GitHub.

Appendix: source

Thrown at kernel/util/minimax_image.go:70

		Prompt string `json:"prompt"`
		Size   string `json:"size"`
		N      int    `json:"n"`
	}
	err := json.NewDecoder(req.Body).Decode(&input)
	req.Body.Close()
	if err != nil {
		return nil, err
	}
	payload := map[string]any{
		"model": input.Model, "prompt": input.Prompt, "n": input.N,
		"response_format": "url", "prompt_optimizer": true,
	}
	if input.Size == "" || input.Size == "auto" {
		payload["aspect_ratio"] = "1:1"
	} else {
		dimensions := strings.Split(input.Size, "x")
		if len(dimensions) != 2 {
			return nil, errors.New("MiniMax image size must be WIDTHxHEIGHT")
		}
		width, widthErr := strconv.Atoi(dimensions[0])
		height, heightErr := strconv.Atoi(dimensions[1])
		if widthErr != nil || heightErr != nil || width <= 0 || height <= 0 {
			return nil, errors.New("MiniMax image dimensions must be positive integers")
		}
		payload["width"], payload["height"] = width, height
	}
	body, err := json.Marshal(payload)
	if err != nil {
		return nil, err
	}
	converted := req.Clone(req.Context())
	converted.URL.Path = strings.TrimSuffix(req.URL.Path, "/images/generations") + "/image_generation"
	converted.URL.RawPath = ""
	converted.Body = io.NopCloser(bytes.NewReader(body))
	converted.ContentLength = int64(len(body))
	converted.GetBody = func() (io.ReadCloser, error) { return io.NopCloser(bytes.NewReader(body)), nil }

View on GitHub (pinned to 9f775e8a12)