{"record":{"id":"05de02e5f99d584d","repo":"decolua/9router","slug":"mimo-tts-error-res-status","errorCode":null,"errorMessage":"MiMo TTS error (${res.status})","messagePattern":"MiMo TTS error \\((.+?)\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"open-sse/handlers/ttsProviders/xiaomi-mimo.js","lineNumber":55,"sourceCode":"    body: JSON.stringify({\n      model: modelId,\n      stream: false,\n      messages,\n      audio: {\n        format: \"wav\",\n        voice: voiceId || DEFAULT_VOICE,\n      },\n    }),\n  });\n\n  const rawText = await res.text();\n  let data = {};\n  if (rawText) {\n    try { data = JSON.parse(rawText); } catch { data = {}; }\n  }\n\n  if (!res.ok) {\n    throw new Error(data?.error?.message || rawText || `MiMo TTS error (${res.status})`);\n  }\n\n  const audio = data?.choices?.[0]?.message?.audio?.data;\n  if (!audio) throw new Error(data?.error?.message || \"MiMo TTS returned no audio\");\n\n  return {\n    base64: audio,\n    format: data?.choices?.[0]?.message?.audio?.format || \"wav\",\n  };\n}\n","sourceCodeStart":37,"sourceCodeEnd":66,"githubUrl":"https://github.com/decolua/9router/blob/90b52e06ffd666b7929554211474d01588f6b1f8/open-sse/handlers/ttsProviders/xiaomi-mimo.js#L37-L66","documentation":"Thrown when the MiMo TTS upstream returns a non-2xx HTTP status. The handler parses the raw body as JSON (when possible) and prefers data.error.message, then rawText, then this status-code template. Any upstream rejection — auth, quota, invalid voice/model — lands here.","triggerScenarios":"MiMo API responds 401 (bad key), 400 (invalid modelId/voiceId/style/language), 429 (rate limit), or 5xx; body may or may not be JSON, hence the layered fallbacks.","commonSituations":"Expired Xiaomi keys, requesting a voiceId unavailable to the account, style/language parameters not accepted by the deployed MiMo version, or gateway/proxy errors returning HTML that can't be JSON-parsed.","solutions":["Check the HTTP status in the message: 401 -> key, 400 -> model/voice params, 429 -> rate limit","Verify the model (default mimo-v2.5-tts) and voiceId are valid for your Xiaomi account","Log rawText to see the real upstream error when JSON parsing fails","Retry with backoff on 429/5xx","Confirm regional endpoint access for the Xiaomi API"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if (!credentials?.apiKey) throw new Error(\"MiMo TTS: missing API key\");\nif (typeof text !== \"string\" || !text.trim()) throw new Error(\"MiMo TTS: text required\");","typeGuard":"function isMiMoHttpError(e) {\n  return e instanceof Error && /^MiMo TTS error \\(\\d{3}\\)$/.test(e.message);\n}","tryCatchPattern":"try {\n  return await synthesizeMiMo(text, model, key, style, language);\n} catch (e) {\n  const m = e.message.match(/MiMo TTS error \\((\\d{3})\\)/);\n  if (m && (m[1] === \"429\" || m[1].startsWith(\"5\"))) return retryWithBackoff(() => synthesizeMiMo(text, model, key, style, language));\n  throw e;\n}","preventionTips":["Validate voiceId/style/language against the MiMo docs for your account tier","Log rawText when body JSON parsing fails so real errors aren't lost","Back off on 429/5xx before retrying","Track key validity and refresh before expiry"],"tags":["tts","xiaomi","mimo","http-error","upstream"],"backgroundTag":"upstream-http-error","analyzedSha":"90b52e06ffd666b7929554211474d01588f6b1f8","analyzedAt":"2026-08-30T21:05:45.952Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}