{"record":{"id":"a7109d725355d13a","repo":"BerriAI/litellm","slug":"response-cannot-be-casted-to-ocicompletionresponse","errorCode":null,"errorMessage":"Response cannot be casted to OCICompletionResponse: {e}","messagePattern":"Response cannot be casted to OCICompletionResponse: (.+?)","errorType":"http","errorClass":"OCIError","httpStatus":null,"severity":"error","filePath":"litellm/llms/oci/chat/generic.py","lineNumber":311,"sourceCode":"    ]\n\n\n# ---------------------------------------------------------------------------\n# Response parsing\n# ---------------------------------------------------------------------------\n\n\ndef handle_generic_response(\n    json_data: dict,\n    model: str,\n    model_response: ModelResponse,\n    raw_response: httpx.Response,\n) -> ModelResponse:\n    \"\"\"Parse a non-streaming GENERIC OCI response into a LiteLLM ModelResponse.\"\"\"\n    try:\n        completion_response: Final = OCICompletionResponse(**json_data)\n    except (TypeError, ValidationError) as e:\n        raise OCIError(\n            message=f\"Response cannot be casted to OCICompletionResponse: {e}\",\n            status_code=raw_response.status_code,\n        )\n\n    iso_str: Final = completion_response.chatResponse.timeCreated\n    dt: Final = datetime.datetime.fromisoformat(iso_str.replace(\"Z\", \"+00:00\"))\n    model_response.created = int(dt.timestamp())\n    model_response.model = completion_response.modelId\n\n    if not completion_response.chatResponse.choices:\n        raise OCIError(\n            message=\"OCI response contained no choices\",\n            status_code=raw_response.status_code,\n        )\n\n    response_choice: Final = completion_response.chatResponse.choices[0]\n    message: Final = model_response.choices[0].message\n    response_message: Final = response_choice.message","sourceCodeStart":293,"sourceCodeEnd":329,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/oci/chat/generic.py#L293-L329","documentation":"Error \"Response cannot be casted to OCICompletionResponse: {e}\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/llms/oci/chat/generic.py:311 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The OCI response did not match the expected schema; see the wrapped exception."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}