{"record":{"id":"68839558770f0566","repo":"danny-avila/LibreChat","slug":"invalid-response-from-the-stt-api","errorCode":null,"errorMessage":"Invalid response from the STT API","messagePattern":"Invalid response from the STT API","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"api/server/services/Files/Audio/STTService.js","lineNumber":319,"sourceCode":"\n    const [url, data, headers] = strategy.call(\n      this,\n      sttSchema,\n      audioReadStream,\n      audioFile,\n      language,\n    );\n\n    const options = { headers };\n\n    applyAxiosProxyConfig(options, url);\n    applySSRFSafeAgentIfDirect(options, url, allowedAddresses);\n\n    try {\n      const response = await axios.post(url, data, options);\n\n      if (response.status !== 200) {\n        throw new Error('Invalid response from the STT API');\n      }\n\n      if (!response.data || !response.data.text) {\n        throw new Error('Missing data in response from the STT API');\n      }\n\n      return response.data.text.trim();\n    } catch (error) {\n      logAxiosError({ message: `STT request failed for provider ${provider}:`, error });\n      throw error;\n    }\n  }\n\n  /**\n   * Processes a speech-to-text request.\n   * @async\n   * @param {Object} req - The request object.\n   * @param {Object} res - The response object.","sourceCodeStart":301,"sourceCodeEnd":337,"githubUrl":"https://github.com/danny-avila/LibreChat/blob/5ff282f9006c436e561de1afd39a481bea1ef0d8/api/server/services/Files/Audio/STTService.js#L301-L337","documentation":"After axios.post returns, sttRequest checks response.status; anything other than 200 throws. The surrounding try/catch logs the failure via logAxiosError (which records the upstream status/body) and re-throws, so callers see 'Invalid response from the STT API' while the detailed status lives in the log. Non-200 usually means auth (401/403), bad request (400), throttling (429), or upstream error (5xx).","triggerScenarios":"Azure/OpenAI-compatible STT endpoint returns a non-200 status: wrong apiKey (401), wrong deployment/instance (404), stale api-version (400), rate limit (429), or provider outage (5xx).","commonSituations":"Rotated key not updated in config; deployment deleted in Azure; apiVersion pinned to a deprecated value; burst of requests hitting a throttle; transient provider 5xx.","solutions":["Read the logAxiosError output to get the real upstream status and body.","Verify the provider apiKey, instanceName, deploymentName, and apiVersion in librechat.yaml.","For 429/5xx, retry with exponential backoff; for 401/403 rotate and re-set the key.","Confirm the resolved URL points at the intended STT deployment."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const text = await stt.sttRequest(provider, sttSchema, { audioBuffer, audioFile, language }, allowedAddresses);\n} catch (err) {\n  // logAxiosError already recorded the upstream status/body server-side\n  if (/Invalid response from the STT API/.test(err.message)) {\n    return res.status(502).json({ error: 'STT provider returned an error status' });\n  }\n  throw err;\n}","preventionTips":["Treat non-200 as expected from upstreams; surface a 502 to the client and log the real status.","Keep apiKey/deployment/apiVersion in config so they can be rotated without code changes.","Add retry-with-backoff for 429 and 5xx only, never for 4xx auth errors."],"tags":["stt","network","upstream","http-status"],"backgroundTag":null,"analyzedSha":"5ff282f9006c436e561de1afd39a481bea1ef0d8","analyzedAt":"2026-08-12T21:38:08.145Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}