{"record":{"id":"a487549364b955bc","repo":"BerriAI/litellm","slug":"raw-response-text-a48754","errorCode":null,"errorMessage":"raw_response.text","messagePattern":"raw_response\\.text","errorType":"http","errorClass":"MistralAudioTranscriptionException","httpStatus":null,"severity":"error","filePath":"litellm/llms/mistral/audio_transcription/transformation.py","lineNumber":135,"sourceCode":"\n        files: Final = {\n            \"file\": (\n                processed_audio.filename,\n                processed_audio.file_content,\n                processed_audio.content_type,\n            )\n        }\n\n        return AudioTranscriptionRequestData(data=form_fields, files=files)\n\n    def transform_audio_transcription_response(\n        self,\n        raw_response: httpx.Response,\n    ) -> TranscriptionResponse:\n        try:\n            response_json: Final = raw_response.json()\n        except Exception:\n            raise MistralAudioTranscriptionException(\n                message=raw_response.text,\n                status_code=raw_response.status_code,\n                headers=raw_response.headers,\n            )\n\n        text: Final = response_json.get(\"text\") or \"\"\n        response: Final = TranscriptionResponse(text=text)\n\n        # Preserve Mistral-specific fields (e.g. diarization segments)\n        if \"segments\" in response_json:\n            response[\"segments\"] = response_json[\"segments\"]\n        if \"language\" in response_json:\n            response[\"language\"] = response_json[\"language\"]\n\n        response._hidden_params = response_json\n        return response\n","sourceCodeStart":117,"sourceCodeEnd":152,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/mistral/audio_transcription/transformation.py#L117-L152","documentation":"Raised by litellm's Mistral audio transcription transformer when raw_response.json() fails: the Mistral transcription endpoint returned a non-JSON body. The exception message is the raw response text, and the upstream status code and headers are propagated, so an auth failure (401) keeps its real status.","triggerScenarios":"Calling litellm.transcription() with a mistral/* audio model when the API returns an error body (plain text or HTML) instead of JSON: invalid MISTRAL_API_KEY, unsupported audio format, file too large, or a gateway 502/504 page.","commonSituations":"Missing/rotated MISTRAL_API_KEY, sending an audio codec Mistral's transcription endpoint does not accept, exceeding file size limits, or routing through a proxy that returns HTML error pages.","solutions":["Check the exception's status_code and message — the message is the literal upstream body and pinpoints the cause.","Validate MISTRAL_API_KEY is set and active for the Mistral transcription product.","Convert audio to a supported format (flac/mp3/mp4/wav/webm/m4a) and confirm the file extension matches the content.","Reduce file size or chunk long audio if upstream rejects large payloads.","If using a custom api_base, confirm it points at Mistral's transcription route, not the chat completions route."],"exampleFix":"# before\nresult = litellm.transcription(model=\"mistral/mistral-large\", file=open(f, \"rb\"))\n\n# after — pre-validate the file and catch with status context\nfrom litellm.exceptions import APIError\ntry:\n    with open(path, \"rb\") as f:\n        result = litellm.transcription(model=\"mistral/mistral-large\", file=f)\nexcept APIError as e:\n    if \"401\" in str(getattr(e, \"status_code\", \"\")):\n        raise RuntimeError(\"Bad MISTRAL_API_KEY\") from e\n    raise","handlingStrategy":"try-catch","validationCode":"import os, pathlib\nassert os.getenv(\"MISTRAL_API_KEY\"), \"MISTRAL_API_KEY not set\"\nassert pathlib.Path(audio_path).stat().st_size > 0, \"audio file is empty\"","typeGuard":null,"tryCatchPattern":"from litellm.exceptions import APIError\ntry:\n    result = litellm.transcription(model=\"mistral/mistral-large\", file=f)\nexcept APIError as e:\n    status = getattr(e, \"status_code\", None)\n    if status == 401:\n        raise RuntimeError(\"Invalid MISTRAL_API_KEY\") from e\n    if status and 502 <= status <= 504:\n        return retry_later()  # transient gateway\n    raise","preventionTips":["Send audio in a Mistral-supported container (flac/mp3/mp4/wav/webm/m4a).","Verify the file's extension matches its actual codec.","Keep the auth key in env/secret manager and rotate before expiry."],"tags":["mistral","audio-transcription","json-parse","api-key"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}