{"record":{"id":"04e566a98779576e","repo":"siyuan-note/siyuan","slug":"minimax-image-generation-failed","errorCode":null,"errorMessage":"MiniMax image generation failed","messagePattern":"MiniMax image generation failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/util/minimax_image.go","lineNumber":111,"sourceCode":"\tif resp.StatusCode < 200 || resp.StatusCode >= 300 {\n\t\tresp.Body.Close()\n\t\treturn nil, fmt.Errorf(\"MiniMax image request failed with HTTP status %d\", resp.StatusCode)\n\t}\n\tvar output struct {\n\t\tData struct {\n\t\t\tURLs []string `json:\"image_urls\"`\n\t\t} `json:\"data\"`\n\t\tBaseResp *struct {\n\t\t\tStatusCode int `json:\"status_code\"`\n\t\t} `json:\"base_resp\"`\n\t}\n\terr = json.NewDecoder(io.LimitReader(resp.Body, 1024*1024)).Decode(&output)\n\tresp.Body.Close()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif output.BaseResp == nil || output.BaseResp.StatusCode != 0 {\n\t\treturn nil, errors.New(\"MiniMax image generation failed\")\n\t}\n\tif len(output.Data.URLs) == 0 || output.Data.URLs[0] == \"\" {\n\t\treturn nil, errors.New(\"MiniMax image model returned no image\")\n\t}\n\tdata := make([]map[string]string, 0, len(output.Data.URLs))\n\tfor _, imageURL := range output.Data.URLs {\n\t\tdata = append(data, map[string]string{\"url\": imageURL})\n\t}\n\tbody, err = json.Marshal(map[string]any{\"data\": data})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tresp.Body = io.NopCloser(bytes.NewReader(body))\n\tresp.ContentLength = int64(len(body))\n\tresp.Header.Set(\"Content-Length\", strconv.Itoa(len(body)))\n\treturn resp, nil\n}\n","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/util/minimax_image.go#L93-L129","documentation":"MiniMax wraps its business result in base_resp with a status_code field; 0 means success. This error is thrown when the HTTP call succeeded (2xx) but the JSON body has no base_resp, or base_resp.status_code is non-zero, meaning MiniMax's application-level API failed (e.g. invalid model, content-policy rejection, account issue). The specific MiniMax status code is not surfaced in the error message, so consult MiniMax docs for the code.","triggerScenarios":"The transport received a 2xx response from /v1/image_generation whose decoded body either lacks base_resp or carries base_resp.status_code != 0 — e.g. invalid API key accepted at gateway but rejected by the service, unsupported model name, prompt blocked by content moderation, or account balance exhausted.","commonSituations":"Using an OpenAI-only model name (like dall-e-3) against MiniMax, a MiniMax account with insufficient balance, prompts triggering content filters, or a proxy returning 200 with a non-MiniMax body (e.g. HTML login page) so base_resp is missing.","solutions":["Log or capture the raw response body and check base_resp.status_code / msg against MiniMax's error-code documentation","Verify the model name is a valid MiniMax image model (not an OpenAI one)","Check the MiniMax account balance and API key validity in the MiniMax console","If base_resp is entirely missing, confirm no proxy/gateway is intercepting the request and returning its own 200 page","Retry after fixing parameters; content-filter rejections require changing the prompt"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if !slices.Contains(validMiniMaxImageModels, model) {\n    return fmt.Errorf(\"model %q is not a MiniMax image model\", model)\n}","typeGuard":"// Go: inspect the returned error text since the MiniMax status code is not embedded\nif err != nil && err.Error() == \"MiniMax image generation failed\" { /* fetch raw body/logs for base_resp.status_code */ }","tryCatchPattern":"data, err := generateImage(req)\nif err != nil && err.Error() == \"MiniMax image generation failed\" {\n    // check account balance, model name, prompt against content policy, then retry\n    return fmt.Errorf(\"minimax generation rejected (check balance/model/prompt): %w\", err)\n}","preventionTips":["Use only model names valid for MiniMax image generation","Keep the MiniMax account funded and the key active","Avoid prompts likely to trip content moderation","Ensure no proxy returns its own 200 HTML responses"],"tags":["minimax","image-generation","api","unexpected-response"],"backgroundTag":"api-error-response","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}