CherryHQ/cherry-studio · error · APICallError
Invalid JSON response from MiniMax
Error message
Invalid JSON response from MiniMax
What it means
Thrown as an `APICallError` when `JSON.parse` fails on a 2xx MiniMax response body. A successful HTTP status with a non-JSON body means the response did not come from the MiniMax image API as expected — the original `parse` error is chained as `cause`, and the raw body is preserved on the error for inspection.
Source
Thrown at src/main/ai/provider/custom/minimax/minimaxImageModel.ts:105
const headersRecord = responseHeaders(response)
const responseBody = await response.text()
if (!response.ok) {
throw new APICallError({
message: responseBody || response.statusText,
url,
requestBodyValues: body,
statusCode: response.status,
responseHeaders: headersRecord,
responseBody
})
}
let parsed: MinimaxImageResponse
try {
parsed = JSON.parse(responseBody) as MinimaxImageResponse
} catch (cause) {
throw new APICallError({
message: 'Invalid JSON response from MiniMax',
cause,
url,
requestBodyValues: body,
statusCode: response.status,
responseHeaders: headersRecord,
responseBody
})
}
if (parsed.base_resp?.status_code && parsed.base_resp.status_code !== 0) {
throw new APICallError({
message: parsed.base_resp.status_msg || `MiniMax error ${parsed.base_resp.status_code}`,
url,
requestBodyValues: body,
statusCode: response.status,
responseHeaders: headersRecord,
responseBodyView on GitHub (pinned to 726446b54c)
Solutions
- Inspect `error.responseBody` to see what was actually returned (HTML, empty, truncated).
- Verify the MiniMax `baseURL`/endpoint is correct and points at the API host, not a web page.
- Retry — transient proxy/maintenance pages often clear up; if persistent, check network/proxy config.
Defensive patterns
Strategy: try-catch
Type guard
const isInvalidJsonError = (e: unknown): boolean => e instanceof APICallError && /Invalid JSON response/.test(e.message)
Try / catch
try {
await model.doGenerate(opts)
} catch (e) {
if (e instanceof APICallError && /Invalid JSON response/.test(e.message)) {
// inspect e.responseBody — likely a proxy/maintenance page; retry
}
throw e
} Prevention
- Verify the MiniMax baseURL points at the API host, not a web page
- Retry once for transient proxy/maintenance pages
- Log responseBody to diagnose non-JSON returns
When it happens
Trigger: A proxy or CDN returned an HTML error page with 200; MiniMax returned a maintenance/interstitial page; a gateway between the app and MiniMax altered the response; an empty or truncated body.
Common situations: Corporate proxy intercepting the request; MiniMax briefly serving a non-API page during an incident; a response truncation from a network glitch; misconfigured `baseURL` pointing at a web page.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Invalid JSON from Feishu registration API: ${text.slice(0, 2
- 0
- responseBody || response.statusText
- parsed.base_resp.status_msg || `MiniMax error ${parsed.base_
- Invalid JSON response from SiliconFlow
AI-assisted analysis of CherryHQ/cherry-studio@726446b54c (2026-08-12).
Data as JSON: /api/errors/3f37e8304898b35d.
Report an issue: GitHub.