BerriAI/litellm · error · BytezError
str(json["error"])
Error message
str(json["error"])
What it means
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.
Source
Thrown at litellm/llms/bytez/chat/transformation.py:197
self,
model: str,
raw_response: httpx.Response,
model_response: ModelResponse,
logging_obj: LiteLLMLoggingObj,
request_data: dict,
messages: list[AllMessageValues],
optional_params: dict,
litellm_params: dict,
encoding: Any,
api_key: str | None = None,
json_mode: bool | None = None,
) -> ModelResponse:
json: Final = raw_response.json()
error: Final = json.get("error")
if error is not None:
raise BytezError(
message=str(json["error"]),
status_code=raw_response.status_code,
)
# set meta data here
model_response.created = int(time.time())
model_response.model = model
# Add the output
output: Final = json.get("output")
message: Final = model_response.choices[0].message
message.content = output["content"][0]["text"]
messages = adapt_messages_to_bytez_standard(messages=messages)
# NOTE We are approximating tokens, to get the true values we will need to update our BEView on GitHub (pinned to 77b7c6c40c)
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.
Defensive patterns
Strategy: try-catch
Try / catch
from litellm.llms.bytez.common_utils import BytezError
try:
resp = litellm.completion(model="bytez/org/model", messages=msgs)
except BytezError as e:
if e.status_code in (429, 500, 503):
# transient: retry with backoff
...
elif e.status_code in (401, 402, 403):
raise RuntimeError(f"Bytez account/key problem: {e.message[:200]}") from e
else:
raise Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- No audio part found in the response
- Mavvrik FOCUS destination: response missing 'url' field: {re
- ReplicateException - {original_exception}
- AzureException APIError - {message}
- APIError: {exception_provider} - {error_str}
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/e93e950f0767e6f5.
Report an issue: GitHub.