{"record":{"id":"447e96de3011759a","repo":"BerriAI/litellm","slug":"failed-to-parse-prompt-response-for-prompt-id","errorCode":null,"errorMessage":"Failed to parse prompt response for '{prompt_id}': {e}","messagePattern":"Failed to parse prompt response for '(.+?)': (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/integrations/generic_prompt_management/generic_prompt_manager.py","lineNumber":130,"sourceCode":"        params: Final = {\n            \"prompt_id\": prompt_id,\n            **(self.additional_provider_specific_query_params or {}),\n        }\n        http_client: Final = _get_httpx_client()\n\n        try:\n            response: Final = http_client.get(\n                url,\n                params=params,\n                headers=self._get_headers(),\n            )\n\n            response.raise_for_status()\n            return response.json()\n        except httpx.HTTPError as e:\n            raise Exception(f\"Failed to fetch prompt '{prompt_id}' from API: {e}\")\n        except json.JSONDecodeError as e:\n            raise Exception(f\"Failed to parse prompt response for '{prompt_id}': {e}\")\n\n    async def async_fetch_prompt_from_api(\n        self, prompt_id: str | None, prompt_spec: PromptSpec | None\n    ) -> dict[str, Any]:\n        \"\"\"\n        Fetch a prompt from the API asynchronously.\n        \"\"\"\n        if prompt_id is None and prompt_spec is None:\n            raise ValueError(\"prompt_id or prompt_spec is required\")\n\n        url: Final = f\"{self.api_base}/beta/litellm_prompt_management\"\n        params: Final = {\n            \"prompt_id\": prompt_id,\n            **(\n                prompt_spec.litellm_params.provider_specific_query_params\n                if prompt_spec and prompt_spec.litellm_params.provider_specific_query_params\n                else {}\n            ),","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/integrations/generic_prompt_management/generic_prompt_manager.py#L112-L148","documentation":"Raised by GenericPromptManager._fetch_prompt_from_api (sync path) when response.json() fails with json.JSONDecodeError — the prompt management API returned a 2xx response whose body is not valid JSON. This means the endpoint answered but is not serving the expected API (e.g. an HTML login page or a plain-text error page was returned).","triggerScenarios":"api_base points at a web server that returns HTML (a static site, a login redirect page, a reverse-proxy error page) with status 200; a CDN or WAF intercepting the request and returning an interstitial; the URL missing a path segment so the server serves its root page.","commonSituations":"Pointing api_base at a company portal domain instead of the actual API host; an nginx ingress configured to serve the frontend on the same path; an auth proxy that returns a 200 HTML login form when the session cookie is missing.","solutions":["Confirm {api_base}/beta/litellm_prompt_management returns JSON: curl it directly and inspect Content-Type and body.","If an auth proxy is in front, make sure the api_key is passed in a way the proxy accepts (usually an Authorization header) so it forwards to the real API.","Adjust api_base to include the correct path prefix if the API is mounted under one (e.g. https://host/litellm)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import httpx\n\ndef assert_prompt_api_returns_json(api_base: str, prompt_id: str) -> None:\n    resp = httpx.get(f\"{api_base}/beta/litellm_prompt_management\", params={\"prompt_id\": prompt_id}, timeout=10)\n    ctype = resp.headers.get(\"content-type\", \"\")\n    if \"json\" not in ctype:\n        raise RuntimeError(\n            f\"api_base is not serving JSON (content-type={ctype!r}); got an HTML/plain-text page instead\"\n        )","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify Content-Type of the prompt endpoint is application/json before wiring it into litellm.","Do not point api_base at UI domains or domains behind SSO login pages.","Include the API path prefix in api_base if the service is mounted under one."],"tags":["http","json","prompt-management","misconfiguration"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}