BerriAI/litellm · error · OCIError
Response cannot be casted to OCICompletionResponse: {e}
Error message
Response cannot be casted to OCICompletionResponse: {e} What it means
Error "Response cannot be casted to OCICompletionResponse: {e}" thrown in BerriAI/litellm.
Source
Thrown at litellm/llms/oci/chat/generic.py:311
]
# ---------------------------------------------------------------------------
# Response parsing
# ---------------------------------------------------------------------------
def handle_generic_response(
json_data: dict,
model: str,
model_response: ModelResponse,
raw_response: httpx.Response,
) -> ModelResponse:
"""Parse a non-streaming GENERIC OCI response into a LiteLLM ModelResponse."""
try:
completion_response: Final = OCICompletionResponse(**json_data)
except (TypeError, ValidationError) as e:
raise OCIError(
message=f"Response cannot be casted to OCICompletionResponse: {e}",
status_code=raw_response.status_code,
)
iso_str: Final = completion_response.chatResponse.timeCreated
dt: Final = datetime.datetime.fromisoformat(iso_str.replace("Z", "+00:00"))
model_response.created = int(dt.timestamp())
model_response.model = completion_response.modelId
if not completion_response.chatResponse.choices:
raise OCIError(
message="OCI response contained no choices",
status_code=raw_response.status_code,
)
response_choice: Final = completion_response.chatResponse.choices[0]
message: Final = model_response.choices[0].message
response_message: Final = response_choice.messageView on GitHub (pinned to 6c2dcb801b)
Solutions
- The OCI response did not match the expected schema; see the wrapped exception.
When it happens
Trigger: Thrown at litellm/llms/oci/chat/generic.py:311 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/a7109d725355d13a.
Report an issue: GitHub.