{"record":{"id":"21734c581f8d5930","repo":"calesthio/OpenMontage","slug":"minimax-image-prompt-must-not-exceed-1500-characte","errorCode":null,"errorMessage":"MiniMax image prompt must not exceed 1500 characters.","messagePattern":"MiniMax image prompt must not exceed 1500 characters\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tools/graphics/minimax_image.py","lineNumber":182,"sourceCode":"            path = path.with_suffix(\".png\")\n        if count == 1:\n            return [path]\n        return [\n            path.with_name(f\"{path.stem}_{index}{path.suffix}\")\n            for index in range(1, count + 1)\n        ]\n\n    @staticmethod\n    def _build_payload(inputs: dict[str, Any]) -> dict[str, Any]:\n        model = inputs.get(\"model\", DEFAULT_MODEL)\n        if model not in MODELS:\n            raise ValueError(f\"Unsupported MiniMax image model '{model}'.\")\n\n        prompt = inputs.get(\"prompt\")\n        if not isinstance(prompt, str) or not prompt:\n            raise ValueError(\"MiniMax image generation requires 'prompt'.\")\n        if len(prompt) > 1500:\n            raise ValueError(\"MiniMax image prompt must not exceed 1500 characters.\")\n\n        width = inputs.get(\"width\")\n        height = inputs.get(\"height\")\n        if (width is None) != (height is None):\n            raise ValueError(\"MiniMax image width and height must be set together.\")\n\n        payload: dict[str, Any] = {\n            \"model\": model,\n            \"prompt\": prompt,\n            \"response_format\": inputs.get(\"response_format\", \"url\"),\n            \"n\": inputs.get(\"n\", 1),\n            \"prompt_optimizer\": inputs.get(\"prompt_optimizer\", False),\n        }\n        for field in (\n            \"subject_reference\",\n            \"aspect_ratio\",\n            \"width\",\n            \"height\",","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/tools/graphics/minimax_image.py#L164-L200","documentation":"Raised by MiniMaxImage._build_payload when the prompt string exceeds 1500 characters, which is the MiniMax image API's documented maximum prompt length. The tool enforces the limit locally so the request fails before hitting the server and burning a call.","triggerScenarios":"Feeding whole articles, scripts, or concatenated style descriptors as the prompt; concatenating prompt plus negative prompt plus JSON metadata into one string.","commonSituations":"Agent pipelines that dump long context into 'prompt'; reuse of LLM-generated captions without truncation.","solutions":["Trim or summarize the prompt to under 1500 chars","Move style/quality boilerplate into shorter directives or drop redundancy","Truncate defensively: prompt = prompt[:1500] when length is untrusted"],"exampleFix":"# before\ninputs = {\"prompt\": long_article_text}\n# after\ninputs = {\"prompt\": long_article_text[:1500]}","handlingStrategy":"validation","validationCode":"MAX = 1500\nif len(prompt) > MAX:\n    prompt = prompt[:MAX]\ninputs[\"prompt\"] = prompt","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Summarize instead of truncating when possible (first sentence + key nouns)","Enforce provider prompt limits in a shared pre-flight validator","Track per-provider limits in config, not in ad-hoc code"],"tags":["minimax","image-generation","input-validation","prompt-length"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}