{"record":{"id":"3c80e8b964832d72","repo":"CherryHQ/cherry-studio","slug":"responsebody-response-statustext","errorCode":null,"errorMessage":"responseBody || response.statusText","messagePattern":"responseBody \\|\\| response\\.statusText","errorType":"exception","errorClass":"APICallError","httpStatus":null,"severity":"error","filePath":"src/main/ai/provider/custom/minimax/minimaxImageModel.ts","lineNumber":91,"sourceCode":"      const value = bag[key]\n      if (value !== undefined && value !== '' && value !== null) body[key] = value\n    }\n\n    const url = this.config.url({ path: '/image_generation', modelId: this.modelId })\n    const fetchFn = this.config.fetch ?? globalThis.fetch\n    const response = await fetchFn(url, {\n      method: 'POST',\n      headers: removeUndefinedEntries(\n        combineHeaders(this.config.headers(), headers, { 'Content-Type': 'application/json' })\n      ),\n      body: JSON.stringify(body),\n      signal: abortSignal\n    })\n    const headersRecord = responseHeaders(response)\n    const responseBody = await response.text()\n\n    if (!response.ok) {\n      throw new APICallError({\n        message: responseBody || response.statusText,\n        url,\n        requestBodyValues: body,\n        statusCode: response.status,\n        responseHeaders: headersRecord,\n        responseBody\n      })\n    }\n\n    let parsed: MinimaxImageResponse\n    try {\n      parsed = JSON.parse(responseBody) as MinimaxImageResponse\n    } catch (cause) {\n      throw new APICallError({\n        message: 'Invalid JSON response from MiniMax',\n        cause,\n        url,\n        requestBodyValues: body,","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/CherryHQ/cherry-studio/blob/726446b54cd69ffe51a276638672f6d95ca0768c/src/main/ai/provider/custom/minimax/minimaxImageModel.ts#L73-L109","documentation":"Thrown as an `APICallError` by the MiniMax image model when the HTTP response is not ok. The message is the raw response body text, falling back to `response.statusText` if the body is empty. The error carries `statusCode`, `responseBody`, `responseHeaders`, and the request body for diagnostics.","triggerScenarios":"MiniMax image API returned 4xx/5xx: invalid API key (401), bad request params (400), rate limit (429), or a server error (5xx).","commonSituations":"API key missing or invalid; `n` exceeds the model's max (9); an unsupported `size`/`aspectRatio`; account out of credits; transient MiniMax outage.","solutions":["Read `error.statusCode` and the response body message for the specific rejection.","401 → verify the MiniMax API key; 429 → back off; 400 → validate `n`, `size`, `aspectRatio` against the model's limits.","Check MiniMax account credit/billing status."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"const isApiCallError = (e: unknown): e is APICallError =>\n  e instanceof APICallError","tryCatchPattern":"try {\n  await model.doGenerate(opts)\n} catch (e) {\n  if (e instanceof APICallError) {\n    if (e.statusCode === 401) /* fix API key */\n    else if (e.statusCode === 429) /* back off */\n    else /* inspect e.responseBody for the cause */\n  }\n  throw e\n}","preventionTips":["Validate n (≤9), size, aspectRatio against the model's limits before sending","Branch on statusCode for tailored handling","Check MiniMax credit balance before bulk generation"],"tags":["api-error","http","minimax","auth","quota"],"backgroundTag":null,"analyzedSha":"726446b54cd69ffe51a276638672f6d95ca0768c","analyzedAt":"2026-08-12T17:30:37.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}