{"record":{"id":"44e27d9c139088fc","repo":"BerriAI/litellm","slug":"error-processing-response-e-44e27d","errorCode":null,"errorMessage":"Error processing response: {e}","messagePattern":"Error processing response: (.+?)","errorType":"exception","errorClass":"LangGraphError","httpStatus":null,"severity":"error","filePath":"litellm/llms/langgraph/chat/transformation.py","lineNumber":460,"sourceCode":"\n                prompt_tokens: Final = token_counter(model=\"gpt-3.5-turbo\", messages=messages)\n                completion_tokens = token_counter(model=\"gpt-3.5-turbo\", text=content, count_response_tokens=True)\n                total_tokens: Final = prompt_tokens + completion_tokens\n\n                usage: Final = Usage(\n                    prompt_tokens=prompt_tokens,\n                    completion_tokens=completion_tokens,\n                    total_tokens=total_tokens,\n                )\n                setattr(model_response, \"usage\", usage)\n            except Exception as e:\n                verbose_logger.warning(\"Failed to calculate token usage: %s\", e)\n\n            return model_response\n\n        except Exception as e:\n            verbose_logger.error(\"Error processing LangGraph response: %s\", e)\n            raise LangGraphError(\n                message=f\"Error processing response: {e}\",\n                status_code=raw_response.status_code,\n            )\n\n    def validate_environment(\n        self,\n        headers: dict,\n        model: str,\n        messages: list[AllMessageValues],\n        optional_params: dict,\n        litellm_params: dict,\n        api_key: str | None = None,\n        api_base: str | None = None,\n    ) -> dict:\n        \"\"\"\n        Validate and set up environment for LangGraph requests.\n        \"\"\"\n        headers[\"Content-Type\"] = \"application/json\"","sourceCodeStart":442,"sourceCodeEnd":478,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/langgraph/chat/transformation.py#L442-L478","documentation":"LangGraphConfig.transform_response wraps the whole response conversion in try/except; any exception inside (most often raw_response.json() failing on a non-JSON body, or an unexpected response shape) is re-raised as LangGraphError \"Error processing response: {e}\" with the HTTP status of the original response. The {e} part names the real underlying failure, so read it first.","triggerScenarios":"The /runs/wait (or streamed final) response body is HTML/plain-text (auth page, gateway error) so .json() throws; the JSON parses but is not the expected dict shape; a truncated or wrongly-encoded body from an intermediary proxy.","commonSituations":"api_base pointing at the LangGraph UI page instead of the API; an ingress returning an HTML error page under load; a version of LangGraph server whose response envelope differs from what the extractor expects.","solutions":["Look at the {e} suffix — a JSONDecodeError means non-JSON body, anything else points at the shape","Enable verbose logging and dump raw_response.text to see exactly what the server returned","Point api_base at the LangGraph API root (no UI path, no trailing /runs)","Confirm auth is accepted (JSON error beats an HTML login page)","Reproduce with curl to {api_base}/runs/wait to inspect the raw body"],"exampleFix":"# before: api_base points at the UI -> HTML body -> 'Error processing response: ...'\nlitellm.completion(model=\"langgraph/agent\", api_base=\"https://host/ui/\", messages=[...])\n\n# after\nimport litellm\nlitellm.verbose_logger.setLevel(\"DEBUG\")  # log raw response for diagnosis\nlitellm.completion(model=\"langgraph/agent\", api_base=\"https://host\", messages=[...])","handlingStrategy":"try-catch","validationCode":"import httpx\n\ndef langgraph_serves_json(base: str) -> None:\n    r = httpx.post(\n        f\"{base.rstrip('/')}/runs/wait\",\n        json={\"assistant_id\": \"agent\", \"input\": {\"messages\": []}},\n        timeout=10,\n    )\n    if \"json\" not in r.headers.get(\"content-type\", \"\"):\n        raise RuntimeError(f\"{base} is not a LangGraph API endpoint (content-type={r.headers.get('content-type')!r})\")","typeGuard":null,"tryCatchPattern":"try:\n    resp = litellm.completion(model=\"langgraph/agent\", messages=msgs, api_base=base)\nexcept Exception as e:\n    if \"Error processing response\" in str(getattr(e, \"message\", \"\")):\n        log.error(\"LangGraph returned an unparseable body (HTTP %s); dumping base URL config\", getattr(e, \"status_code\", None))\n    raise","preventionTips":["Point api_base at the LangGraph API root, never the UI route","Verify the endpoint returns JSON with a direct httpx/curl call when onboarding a new server","Enable verbose logging in staging so raw bodies are captured when this fires"],"tags":["langgraph","response-parsing","non-json-response"],"backgroundTag":"response-parsing-failed","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}