{"record":{"id":"898567e56a649bf9","repo":"BerriAI/litellm","slug":"unable-to-parse-response-got-response-data-outp","errorCode":null,"errorMessage":"Unable to parse response. Got={response_data[\"output\"]}","messagePattern":"Unable to parse response\\. Got=(.+?)","errorType":"exception","errorClass":"ReplicateError","httpStatus":422,"severity":"error","filePath":"litellm/llms/replicate/chat/handler.py","lineNumber":44,"sourceCode":"def handle_prediction_response_streaming(\n    prediction_url, api_token, print_verbose, headers: dict, http_client: HTTPHandler\n):\n    previous_output = \"\"\n    output_string = \"\"\n\n    status = \"\"\n    while True and (status not in [\"succeeded\", \"failed\", \"canceled\"]):\n        time.sleep(REPLICATE_POLLING_DELAY_SECONDS)  # prevent being rate limited by replicate\n        print_verbose(f\"replicate: polling endpoint: {prediction_url}\")\n        response = http_client.get(prediction_url, headers=headers)\n        if response.status_code == 200:\n            response_data = response.json()\n            status = response_data[\"status\"]\n            if \"output\" in response_data:\n                try:\n                    output_string = \"\".join(response_data[\"output\"])\n                except Exception:\n                    raise ReplicateError(\n                        status_code=422,\n                        message=\"Unable to parse response. Got={}\".format(response_data[\"output\"]),\n                        headers=response.headers,\n                    )\n                new_output = output_string[len(previous_output) :]\n                print_verbose(f\"New chunk: {new_output}\")\n                yield {\"output\": new_output, \"status\": status}\n                previous_output = output_string\n            status = response_data[\"status\"]\n            if status == \"failed\":\n                replicate_error = response_data.get(\"error\", \"\")\n                raise ReplicateError(\n                    status_code=400,\n                    message=f\"Error: {replicate_error}\",\n                    headers=response.headers,\n                )\n        else:\n            # this can fail temporarily but it does not mean the replicate request failed, replicate request fails when status==\"failed\"","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/replicate/chat/handler.py#L26-L62","documentation":"Output-joining guard in the Replicate streaming poller: response_data['output'] could not be joined into a string (elements are not strings), so the streamed text cannot be reconstructed and a 422 is raised with the raw output payload.","triggerScenarios":"Triggered when the Replicate chat response 'output' field cannot be parsed into the expected format.","commonSituations":"See trigger scenarios.","solutions":["The Replicate response 'output' could not be parsed; log response_data[\"output\"] to inspect its shape.","Check the Replicate model version's output schema."],"exampleFix":"# verify the replicate deployment returns the expected output format.","handlingStrategy":"type-guard","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-14T05:17:10.506Z"}