{"record":{"id":"464bff82d5bd21c7","repo":"rohitg00/agentmemory","slug":"minimax-api-error-response-status-text","errorCode":null,"errorMessage":"MiniMax API error ${response.status}: ${text}","messagePattern":"MiniMax API error (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/providers/minimax.ts","lineNumber":61,"sourceCode":"    const url = `${this.baseUrl}/v1/messages`\n    const response = await fetchWithTimeout(url, {\n      method: 'POST',\n      headers: {\n        'Content-Type': 'application/json',\n        'x-api-key': this.apiKey,\n        'anthropic-version': '2023-06-01',\n      },\n      body: JSON.stringify({\n        model: this.model,\n        max_tokens: this.maxTokens,\n        system: systemPrompt,\n        messages: [{ role: 'user', content: userPrompt }],\n      }),\n    })\n\n    if (!response.ok) {\n      const text = await response.text()\n      throw new Error(`MiniMax API error ${response.status}: ${text}`)\n    }\n\n    const data = (await response.json()) as {\n      content?: Array<{ type: string; text?: string }>\n    }\n    const textBlock = data.content?.find((b) => b.type === 'text')\n    return textBlock?.text ?? ''\n  }\n}\n","sourceCodeStart":43,"sourceCodeEnd":71,"githubUrl":"https://github.com/rohitg00/agentmemory/blob/e04ba88819c365c9acf9d6661ea802143e728bd6/src/providers/minimax.ts#L43-L71","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the appended body text — it contains MiniMax's own error JSON stating the cause (invalid key, rate limit, bad model)","Verify the MiniMax API key is valid and not expired; rotate it if necessary","Retry with backoff if status is 429 or 5xx (or rely on the resilient/circuit-breaker wrapper)","Shrink the prompt sent to compress/summarize if the body indicates a length limit","Check MiniMax status/deprecation notices and update the model name"],"exampleFix":"// before\nawait provider.compress(hugeTranscript); // MiniMax API error 429: {\"error\":\"rate limited\"}\n\n// after\ntry {\n  await provider.compress(chunkText(hugeTranscript));\n} catch (e) {\n  if (String(e).includes('429')) await sleep(backoff());\n  else throw e;\n}","handlingStrategy":"retry","validationCode":"if (!process.env.MINIMAX_API_KEY) throw new Error('MINIMAX_API_KEY not set');\nif (userPrompt.length === 0) throw new Error('Refusing empty MiniMax prompt');","typeGuard":null,"tryCatchPattern":"try {\n  return await minimaxProvider.call(prompt);\n} catch (e) {\n  const m = /MiniMax API error (\\d+)/.exec(String(e));\n  const status = m ? Number(m[1]) : 0;\n  if (status === 429 || status >= 500) return retryWithBackoff(() => minimaxProvider.call(prompt), 3);\n  throw e;\n}","preventionTips":["Route LLM calls through ResilientProvider so the circuit breaker and fallbacks absorb MiniMax outages","Chunk long inputs before compress/summarize to stay under request limits","Monitor the appended error body for 401/402 and alert on credential problems","Use createFallbackProvider with a secondary provider for critical paths"],"tags":["network","api-error","minimax","http-status"],"backgroundTag":"upstream-api-error","analyzedSha":"e04ba88819c365c9acf9d6661ea802143e728bd6","analyzedAt":"2026-08-30T01:07:40.754Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}