{"record":{"id":"5f262ebc27e0567a","repo":"BerriAI/litellm","slug":"e-response-text-5f262e","errorCode":null,"errorMessage":"e.response.text","messagePattern":"e\\.response\\.text","errorType":"exception","errorClass":"BytezError","httpStatus":null,"severity":"error","filePath":"litellm/llms/bytez/chat/transformation.py","lineNumber":274,"sourceCode":"        messages: list,\n        client: HTTPHandler | AsyncHTTPHandler | None = None,\n        json_mode: bool | None = None,\n        signed_json_body: bytes | None = None,\n    ) -> \"BytezCustomStreamWrapper\":\n        if client is None or isinstance(client, AsyncHTTPHandler):\n            client = _get_httpx_client(params={})\n\n        try:\n            response: Final = client.post(\n                api_base,\n                headers=headers,\n                data=json.dumps(data),\n                stream=True,\n                logging_obj=logging_obj,\n                timeout=STREAMING_TIMEOUT,\n            )\n        except httpx.HTTPStatusError as e:\n            raise BytezError(status_code=e.response.status_code, message=e.response.text)\n\n        if response.status_code != 200:\n            raise BytezError(status_code=response.status_code, message=response.text)\n\n        completion_stream: Final = response.iter_text()\n\n        streaming_response: Final = BytezCustomStreamWrapper(\n            completion_stream=completion_stream,\n            model=model,\n            custom_llm_provider=custom_llm_provider,\n            logging_obj=logging_obj,\n        )\n        return streaming_response\n\n    @track_llm_api_timing()\n    async def get_async_custom_stream_wrapper(\n        self,\n        model: str,","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/bytez/chat/transformation.py#L256-L292","documentation":"In the synchronous streaming path, the POST to Bytez is wrapped in `except httpx.HTTPStatusError` which re-raises as BytezError carrying e.response.status_code and the response body text. In practice httpx only raises HTTPStatusError when raise_for_status() is invoked, so the adjacent `status_code != 200` check is the more common path — but either way an HTTP error on the streaming request surfaces as BytezError with the raw body as the message.","triggerScenarios":"stream=True request rejected at the HTTP layer: 401 bad key, 404 wrong model path/URL, 429 rate limit, 5xx from Bytez — the response body text becomes the error message.","commonSituations":"Expired/rotated keys producing 401 HTML/JSON bodies; rate limits during batch jobs; wrong api_base; Bytez incidents returning 502/503 pages that end up verbatim in the exception message.","solutions":["Catch BytezError, log status_code, and branch on it (auth vs rate-limit vs server).","Fix the underlying cause the body text reveals (bad key, bad model URL, quota).","Add retry with exponential backoff for 429/5xx status codes.","For long error bodies, truncate before logging to keep logs readable."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from litellm.llms.bytez.common_utils import BytezError\nimport time\n\nfor attempt in range(3):\n    try:\n        stream = litellm.completion(model=\"bytez/org/model\", messages=msgs, stream=True)\n        break\n    except BytezError as e:\n        if e.status_code in (429, 502, 503) and attempt < 2:\n            time.sleep(2 ** attempt)\n            continue\n        raise","preventionTips":["Branch on status_code instead of parsing the raw body text from the message.","Truncate e.message to a few hundred chars before logging — error pages can be huge."],"tags":["bytez","streaming","http-error","sync"],"backgroundTag":"http-error-response","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","schemaVersion":2},"datasetVersion":"2026-08-24T22:17:12.610Z"}