{"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":"exception","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/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/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":["Log the raw OCI response; the schema changed or an error payload was returned. Check the wrapped error {e} and the OCI model/endpoint configuration."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}