{"record":{"id":"e93e950f0767e6f5","repo":"BerriAI/litellm","slug":"str-json-error","errorCode":null,"errorMessage":"str(json[\"error\"])","messagePattern":"str\\(json\\[\"error\"\\]\\)","errorType":"exception","errorClass":"BytezError","httpStatus":null,"severity":"error","filePath":"litellm/llms/bytez/chat/transformation.py","lineNumber":197,"sourceCode":"        self,\n        model: str,\n        raw_response: httpx.Response,\n        model_response: ModelResponse,\n        logging_obj: LiteLLMLoggingObj,\n        request_data: dict,\n        messages: list[AllMessageValues],\n        optional_params: dict,\n        litellm_params: dict,\n        encoding: Any,\n        api_key: str | None = None,\n        json_mode: bool | None = None,\n    ) -> ModelResponse:\n        json: Final = raw_response.json()\n\n        error: Final = json.get(\"error\")\n\n        if error is not None:\n            raise BytezError(\n                message=str(json[\"error\"]),\n                status_code=raw_response.status_code,\n            )\n\n        # set meta data here\n        model_response.created = int(time.time())\n        model_response.model = model\n\n        # Add the output\n        output: Final = json.get(\"output\")\n\n        message: Final = model_response.choices[0].message\n\n        message.content = output[\"content\"][0][\"text\"]\n\n        messages = adapt_messages_to_bytez_standard(messages=messages)\n\n        # NOTE We are approximating tokens, to get the true values we will need to update our BE","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/bytez/chat/transformation.py#L179-L215","documentation":"After a Bytez chat response arrives, the transformation looks for a top-level 'error' key in the JSON body; if present it raises BytezError with the HTTP status code and str() of the error value. This is how Bytez-side failures (bad model path, insufficient credits, model load problems) surface through litellm.","triggerScenarios":"Requesting a bytez model path that does not exist or is not enabled for your account; out-of-credit or unauthorized account; cold-start model still loading server-side (the 5-minute STREAMING_TIMEOUT comment notes models may need to load); malformed model identifiers.","commonSituations":"Wrong model org/name casing in the bytez model string; free-tier limits; first request to a rarely used model that must be loaded; shared keys rotated without updating config.","solutions":["Catch BytezError and read status_code + message — they carry the upstream reason verbatim.","Fix the model string (correct org/model path) or enable the model in your Bytez account.","Retry with backoff for load-related/transient errors (first-request cold start).","Check account credits/plan if the message indicates billing."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from litellm.llms.bytez.common_utils import BytezError\n\ntry:\n    resp = litellm.completion(model=\"bytez/org/model\", messages=msgs)\nexcept BytezError as e:\n    if e.status_code in (429, 500, 503):\n        # transient: retry with backoff\n        ...\n    elif e.status_code in (401, 402, 403):\n        raise RuntimeError(f\"Bytez account/key problem: {e.message[:200]}\") from e\n    else:\n        raise","preventionTips":["Treat the message text as the upstream Bytez error — it names the real cause (model, credits, auth).","Warm up rarely used models with a cheap first request to absorb cold-start latency."],"tags":["bytez","api-error","response-parsing"],"backgroundTag":"api-error-response","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}