rohitg00/agentmemory · error · Error

MiniMax API error ${response.status}: ${text}

Error message

MiniMax API error ${response.status}: ${text}

What it means

MiniMaxProvider.call throws this whenever the MiniMax HTTP API responds with a non-2xx status; the raw response body text is appended for diagnostics. It is a pass-through of the upstream API's rejection — anything from 401 bad credentials to 429 rate limiting to 5xx outage. The call() method is invoked by compress and summarize.

Source

Thrown at src/providers/minimax.ts:61

    const url = `${this.baseUrl}/v1/messages`
    const response = await fetchWithTimeout(url, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'x-api-key': this.apiKey,
        'anthropic-version': '2023-06-01',
      },
      body: JSON.stringify({
        model: this.model,
        max_tokens: this.maxTokens,
        system: systemPrompt,
        messages: [{ role: 'user', content: userPrompt }],
      }),
    })

    if (!response.ok) {
      const text = await response.text()
      throw new Error(`MiniMax API error ${response.status}: ${text}`)
    }

    const data = (await response.json()) as {
      content?: Array<{ type: string; text?: string }>
    }
    const textBlock = data.content?.find((b) => b.type === 'text')
    return textBlock?.text ?? ''
  }
}

View on GitHub (pinned to e04ba88819)

Solutions

  1. Read the appended body text — it contains MiniMax's own error JSON stating the cause (invalid key, rate limit, bad model)
  2. Verify the MiniMax API key is valid and not expired; rotate it if necessary
  3. Retry with backoff if status is 429 or 5xx (or rely on the resilient/circuit-breaker wrapper)
  4. Shrink the prompt sent to compress/summarize if the body indicates a length limit
  5. Check MiniMax status/deprecation notices and update the model name

Example fix

// before
await provider.compress(hugeTranscript); // MiniMax API error 429: {"error":"rate limited"}

// after
try {
  await provider.compress(chunkText(hugeTranscript));
} catch (e) {
  if (String(e).includes('429')) await sleep(backoff());
  else throw e;
}
Defensive patterns

Strategy: retry

Validate before calling

if (!process.env.MINIMAX_API_KEY) throw new Error('MINIMAX_API_KEY not set');
if (userPrompt.length === 0) throw new Error('Refusing empty MiniMax prompt');

Try / catch

try {
  return await minimaxProvider.call(prompt);
} catch (e) {
  const m = /MiniMax API error (\d+)/.exec(String(e));
  const status = m ? Number(m[1]) : 0;
  if (status === 429 || status >= 500) return retryWithBackoff(() => minimaxProvider.call(prompt), 3);
  throw e;
}

Prevention

When it happens

Trigger: fetch to the MiniMax completions endpoint returns response.ok === false; compress() or summarize() invoked with an invalid/expired API key, a model name MiniMax rejects, a too-large prompt, or during a MiniMax outage; rate limit hit at 429.

Common situations: Expired or revoked MiniMax API key (401); exceeding rate limits (429); malformed request caused by an empty or oversized userPrompt; MiniMax regional endpoint downtime; wrong model identifier after MiniMax deprecates a model version.

Related errors


AI-assisted analysis of rohitg00/agentmemory@e04ba88819 (2026-08-30). Data as JSON: /api/errors/464bff82d5bd21c7. Report an issue: GitHub.