calesthio/OpenMontage · error · ValueError

MiniMax image width and height must be set together.

Error message

MiniMax image width and height must be set together.

What it means

Raised by MiniMaxImage._build_payload when exactly one of 'width'/'height' is provided (XOR check via (width is None) != (height is None)). The API expects dimensions as a pair, so a lone dimension is rejected client-side. Use 'aspect_ratio' alone if you don't need explicit pixel sizes.

Source

Thrown at tools/graphics/minimax_image.py:187

            for index in range(1, count + 1)
        ]

    @staticmethod
    def _build_payload(inputs: dict[str, Any]) -> dict[str, Any]:
        model = inputs.get("model", DEFAULT_MODEL)
        if model not in MODELS:
            raise ValueError(f"Unsupported MiniMax image model '{model}'.")

        prompt = inputs.get("prompt")
        if not isinstance(prompt, str) or not prompt:
            raise ValueError("MiniMax image generation requires 'prompt'.")
        if len(prompt) > 1500:
            raise ValueError("MiniMax image prompt must not exceed 1500 characters.")

        width = inputs.get("width")
        height = inputs.get("height")
        if (width is None) != (height is None):
            raise ValueError("MiniMax image width and height must be set together.")

        payload: dict[str, Any] = {
            "model": model,
            "prompt": prompt,
            "response_format": inputs.get("response_format", "url"),
            "n": inputs.get("n", 1),
            "prompt_optimizer": inputs.get("prompt_optimizer", False),
        }
        for field in (
            "subject_reference",
            "aspect_ratio",
            "width",
            "height",
            "seed",
        ):
            if inputs.get(field) is not None:
                payload[field] = inputs[field]
        return payload

View on GitHub (pinned to 95e1c3d0ab)

Solutions

  1. Set both width and height together, or neither
  2. If only the shape matters, use aspect_ratio instead of explicit dimensions
  3. Validate pairs in your config loader before invoking the tool

Example fix

# before
inputs = {"prompt": "...", "width": 1280}
# after
inputs = {"prompt": "...", "width": 1280, "height": 720}
Defensive patterns

Strategy: validation

Validate before calling

w, h = inputs.get("width"), inputs.get("height")
if (w is None) != (h is None):
    raise ValueError("set width+height together, or use aspect_ratio")

Type guard

def has_paired_dimensions(inputs: dict) -> bool:
    return (inputs.get("width") is None) == (inputs.get("height") is None)

Prevention

When it happens

Trigger: Setting width=1280 but forgetting height; height inherited from a template while width was overridden; passing height=0 (not None) with no width, which still fails the pair rule only if the other is None.

Common situations: Config partial-override patterns (set one dimension, expect the other to default); merging configs where one key was dropped.

Related errors


AI-assisted analysis of calesthio/OpenMontage@95e1c3d0ab (2026-08-15). Data as JSON: /api/errors/f546327edfd2c447. Report an issue: GitHub.