{"record":{"id":"1e1d53e6ced3b959","repo":"BerriAI/litellm","slug":"error-getting-prompt-from-humanloop-e-response-t","errorCode":null,"errorMessage":"Error getting prompt from Humanloop: {e.response.text}","messagePattern":"Error getting prompt from Humanloop: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/integrations/humanloop.py","lineNumber":79,"sourceCode":"        return compiled_prompts\n\n    def _get_prompt_from_id_api(self, humanloop_prompt_id: str, humanloop_api_key: str) -> PromptManagementClient:\n        client: Final = _get_httpx_client()\n\n        base_url: Final = f\"https://api.humanloop.com/v5/prompts/{humanloop_prompt_id}\"\n\n        response: Final = client.get(\n            url=base_url,\n            headers={\n                \"X-Api-Key\": humanloop_api_key,\n                \"Content-Type\": \"application/json\",\n            },\n        )\n\n        try:\n            response.raise_for_status()\n        except httpx.HTTPStatusError as e:\n            raise Exception(f\"Error getting prompt from Humanloop: {e.response.text}\")\n\n        json_response: Final = response.json()\n        template_message: Final = json_response[\"template\"]\n        if isinstance(template_message, dict):\n            template_messages = [template_message]\n        elif isinstance(template_message, list):\n            template_messages = template_message\n        else:\n            raise ValueError(f\"Invalid template message type: {type(template_message)}\")\n        template_model: Final = json_response[\"model\"]\n        optional_params: Final = {}\n        for k, v in json_response.items():\n            if k in litellm.OPENAI_CHAT_COMPLETION_PARAMS:\n                optional_params[k] = v\n        return PromptManagementClient(\n            prompt_id=humanloop_prompt_id,\n            prompt_template=cast(list[AllMessageValues], template_messages),\n            model=template_model,","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/integrations/humanloop.py#L61-L97","documentation":"Exception raised by the Humanloop prompt integration when GET {base_url}/prompts/{id} returns a non-2xx status. The response body text from Humanloop (API error message) is embedded, so the message tells you exactly what Humanloop complained about.","triggerScenarios":"Calling completions with prompt_id for Humanloop when the id doesn't exist (404), the HUMANLOOP_API_KEY is invalid (401), or the API base URL was customized incorrectly; response.raise_for_status() converts the status into httpx.HTTPStatusError which is caught and re-wrapped.","commonSituations":"prompt_id copied from a different Humanloop project/environment (dev vs prod); rotated API key not updated; self-hosted/proxied Humanloop base URL misconfigured; prompt archived or deleted in the Humanloop UI.","solutions":["Read e.response.text in the message — Humanloop states the reason","Verify prompt_id exists in the same Humanloop project the key belongs to","Rotate/refresh HUMANLOOP_API_KEY if 401/403","Check the configured Humanloop base_url override if any"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import httpx, os\n\ndef humanloop_key_ok(prompt_id: str) -> bool:\n    r = httpx.get(\n        f\"https://api.humanloop.com/v4/prompts/{prompt_id}\",\n        headers={\"X-Api-Key\": os.environ[\"HUMANLOOP_API_KEY\"]},\n        timeout=5,\n    )\n    return r.status_code == 200","typeGuard":null,"tryCatchPattern":"try:\n    pmc = get_humanloop_prompt(prompt_id)\nexcept Exception as e:\n    if \"404\" in str(e):\n        raise LookupError(f\"Humanloop prompt {prompt_id} not found in this project\") from e\n    if \"401\" in str(e):\n        raise PermissionError(\"HUMANLOOP_API_KEY invalid\") from e\n    raise","preventionTips":["Validate prompt ids per environment (dev/staging/prod projects differ)","Rotate keys via env var, never hardcode","Log response text on failure — Humanloop explains the reason"],"tags":["humanloop","prompt-management","litellm","http","api-client"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}