{"record":{"id":"83fdccad6112b8ed","repo":"siyuan-note/siyuan","slug":"minimax-image-request-failed-with-http-status-d","errorCode":null,"errorMessage":"MiniMax image request failed with HTTP status %d","messagePattern":"MiniMax image request failed with HTTP status (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/util/minimax_image.go","lineNumber":95,"sourceCode":"\t\tpayload[\"width\"], payload[\"height\"] = width, height\n\t}\n\tbody, err := json.Marshal(payload)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tconverted := req.Clone(req.Context())\n\tconverted.URL.Path = strings.TrimSuffix(req.URL.Path, \"/images/generations\") + \"/image_generation\"\n\tconverted.URL.RawPath = \"\"\n\tconverted.Body = io.NopCloser(bytes.NewReader(body))\n\tconverted.ContentLength = int64(len(body))\n\tconverted.GetBody = func() (io.ReadCloser, error) { return io.NopCloser(bytes.NewReader(body)), nil }\n\tresp, err := t.base.Do(converted)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\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] == \"\" {","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/util/minimax_image.go#L77-L113","documentation":"The MiniMax image transport (miniMaxImageTransport.Do) converts OpenAI-style /images/generations requests into MiniMax /image_generation calls. After issuing the converted HTTP request it checks the response status code; anything outside 200-299 is rejected with this error and the response body is closed and discarded. It means the MiniMax API endpoint refused the request at the HTTP level, so no image payload is available.","triggerScenarios":"Calling the AI image-generation flow with a MiniMax base URL (api.minimax.io/api.minimax.cn/api.minimaxi.com with /v1 path) when MiniMax returns 4xx/5xx: invalid or missing API key (401), malformed request parameters (400), quota exhausted (429), or MiniMax server errors (5xx).","commonSituations":"Developers enter an expired or wrong MiniMax API key, use an unsupported model name, send an invalid size string after transport conversion, or hit MiniMax rate limits during bursts of image generation.","solutions":["Check the HTTP status logged with the error: 401/403 means fix the MiniMax API key in the AI provider settings","429 means rate limiting — retry with backoff or reduce request frequency","400 means the request payload was rejected — verify the model name and size (WIDTHxHEIGHT) are valid for MiniMax","5xx means a MiniMax-side problem — retry later; the response body containing the detailed error message was discarded, so enable request logging if you need the detail","Confirm network/proxy settings allow reaching the MiniMax host"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"u, _ := url.Parse(baseURL)\nif u == nil || u.Scheme != \"https\" || !strings.HasSuffix(strings.TrimRight(u.Path, \"/\"), \"/v1\") {\n    return fmt.Errorf(\"base URL must be https://api.minimax.{io,cn}/v1\")\n}\nif apiKey == \"\" {\n    return fmt.Errorf(\"MiniMax API key is required\")\n}","typeGuard":"// Go: check the concrete error shape\nvar mmErr interface{ Error() string }\nif errors.As(err, &mmErr) && strings.HasPrefix(mmErr.Error(), \"MiniMax image request failed with HTTP status \") { /* handle 4xx/5xx */ }","tryCatchPattern":"data, err := generateImage(req)\nif err != nil {\n    if strings.Contains(err.Error(), \"HTTP status 401\") || strings.Contains(err.Error(), \"HTTP status 403\") {\n        return fmt.Errorf(\"check MiniMax API key: %w\", err)\n    }\n    if strings.Contains(err.Error(), \"HTTP status 429\") {\n        // retry with backoff\n    }\n    return err\n}","preventionTips":["Validate the MiniMax API key before deploying","Keep request frequency under MiniMax rate limits","Verify the base URL is an official MiniMax host with a /v1 path","Log status codes and correlate with MiniMax's error-code docs"],"tags":["http","minimax","image-generation","network"],"backgroundTag":"http-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"}