CherryHQ/cherry-studio · error · APICallError

responseBody || response.statusText

Error message

responseBody || response.statusText

What it means

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.

Source

Thrown at src/main/ai/provider/custom/minimax/minimaxImageModel.ts:91

      const value = bag[key]
      if (value !== undefined && value !== '' && value !== null) body[key] = value
    }

    const url = this.config.url({ path: '/image_generation', modelId: this.modelId })
    const fetchFn = this.config.fetch ?? globalThis.fetch
    const response = await fetchFn(url, {
      method: 'POST',
      headers: removeUndefinedEntries(
        combineHeaders(this.config.headers(), headers, { 'Content-Type': 'application/json' })
      ),
      body: JSON.stringify(body),
      signal: abortSignal
    })
    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,

View on GitHub (pinned to 726446b54c)

Solutions

  1. Read `error.statusCode` and the response body message for the specific rejection.
  2. 401 → verify the MiniMax API key; 429 → back off; 400 → validate `n`, `size`, `aspectRatio` against the model's limits.
  3. Check MiniMax account credit/billing status.
Defensive patterns

Strategy: try-catch

Type guard

const isApiCallError = (e: unknown): e is APICallError =>
  e instanceof APICallError

Try / catch

try {
  await model.doGenerate(opts)
} catch (e) {
  if (e instanceof APICallError) {
    if (e.statusCode === 401) /* fix API key */
    else if (e.statusCode === 429) /* back off */
    else /* inspect e.responseBody for the cause */
  }
  throw e
}

Prevention

When it happens

Trigger: MiniMax image API returned 4xx/5xx: invalid API key (401), bad request params (400), rate limit (429), or a server error (5xx).

Common situations: API key missing or invalid; `n` exceeds the model's max (9); an unsupported `size`/`aspectRatio`; account out of credits; transient MiniMax outage.

Related errors


AI-assisted analysis of CherryHQ/cherry-studio@726446b54c (2026-08-12). Data as JSON: /api/errors/3c80e8b964832d72. Report an issue: GitHub.