{"record":{"id":"c04888f79ab0b714","repo":"moeru-ai/airi","slug":"invalid-request-body-c04888","errorCode":null,"errorMessage":"Invalid request body","messagePattern":"Invalid request body","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/provider-inference/src/providers/cloud/minimax-speech/index.ts","lineNumber":32,"sourceCode":"  name: 'MiniMax Speech',\n  nameLocalize: ({ t }) => t('settings.pages.providers.provider.minimax-speech.title'),\n  description: 'minimax.io',\n  descriptionLocalize: ({ t }) => t('settings.pages.providers.provider.minimax-speech.description'),\n  tasks: ['text-to-speech'],\n  icon: 'i-lobe-icons:minimax',\n  iconColor: 'i-lobe-icons:minimax-color',\n  createProviderConfig: () => minimaxSpeechConfigSchema,\n  createProvider(config) {\n    const apiKey = config.apiKey.trim()\n    const baseUrl = (config.baseUrl || 'https://api.minimax.io').replace(/\\/$/, '')\n\n    return {\n      speech: () => ({\n        baseURL: `${baseUrl}/v1/`,\n        model: 'speech-2.8-hd',\n        fetch: async (_input: RequestInfo | URL, init?: RequestInit) => {\n          if (!init?.body || typeof init.body !== 'string')\n            throw new Error('Invalid request body')\n\n          const body = JSON.parse(init.body) as { input?: string, voice?: string, model?: string }\n          const response = await fetch(`${baseUrl}/v1/t2a_v2`, {\n            method: 'POST',\n            headers: {\n              'Content-Type': 'application/json',\n              'Authorization': `Bearer ${apiKey}`,\n            },\n            body: JSON.stringify({\n              model: body.model || 'speech-2.8-hd',\n              text: body.input ?? '',\n              stream: true,\n              voice_setting: {\n                voice_id: body.voice || 'English_Graceful_Lady',\n                speed: 1,\n                vol: 1,\n                pitch: 0,\n              },","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/moeru-ai/airi/blob/f679616c34f1cf6d282c8d64264242af944b3fed/packages/provider-inference/src/providers/cloud/minimax-speech/index.ts#L14-L50","documentation":"The MiniMax speech (TTS) provider intercepts the SDK's speech fetch and expects the request body to be a JSON string it can parse. If init.body is missing or not a string, this error is thrown, meaning the TTS request never carried a serializable JSON payload.","triggerScenarios":"Calling the speech API with a FormData/Stream/URLSearchParams body instead of JSON, or issuing a GET/empty-body request through the provider's baseURL.","commonSituations":"Manually calling fetch with multipart form-data; a wrapper that JSON.stringify's into an object rather than a string; using an SDK version that streams the body instead of buffering it into init.body.","solutions":["Ensure the TTS request body is a plain JSON string containing at least 'input' (text), 'voice', and 'model'.","Use the provider through its SDK speech helper instead of hand-rolled fetch calls.","Remove middleware that converts the body to FormData or streams.","Pass text via the SDK option (e.g. { input: 'hello' }) so the client serializes JSON."],"exampleFix":"// before\nfetch(baseURL, { method: 'POST', body: formData })\n// after\nfetch(baseURL, {\n  method: 'POST',\n  headers: { 'Content-Type': 'application/json' },\n  body: JSON.stringify({ model: 'speech-2.8-hd', input: text, voice })\n})","handlingStrategy":"validation","validationCode":"const body = JSON.stringify({ model, input: text, voice })\nif (typeof body !== 'string' || !text?.trim()) throw new TypeError('TTS request requires JSON string body with non-empty input')","typeGuard":"const isJsonStringBody = (init?: RequestInit): init is RequestInit & { body: string } => typeof init?.body === 'string'","tryCatchPattern":"try { await tts(text) } catch (e) { if (e.message === 'Invalid request body') { /* send JSON.stringify'd body instead */ } else throw e }","preventionTips":["Send JSON, never FormData, to the TTS endpoint","Let the SDK serialize the body","Don't wrap the provider with body-transforming middleware","Check Content-Type is application/json"],"tags":["tts","speech","request-body","validation"],"backgroundTag":"invalid-argument-format","analyzedSha":"f679616c34f1cf6d282c8d64264242af944b3fed","analyzedAt":"2026-09-08T13:18:15.005Z","contentChangedAt":"2026-09-08T13:18:15.005Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}