{"record":{"id":"80ca232b38dbb802","repo":"BerriAI/litellm","slug":"prompt-id-or-prompt-spec-is-required","errorCode":null,"errorMessage":"prompt_id or prompt_spec is required","messagePattern":"prompt_id or prompt_spec is required","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/generic_prompt_management/generic_prompt_manager.py","lineNumber":109,"sourceCode":"        if self.api_key:\n            headers[\"Authorization\"] = f\"Bearer {self.api_key}\"\n        return headers\n\n    def _fetch_prompt_from_api(self, prompt_id: str | None, prompt_spec: PromptSpec | None) -> dict[str, Any]:\n        \"\"\"\n        Fetch a prompt from the API.\n\n        Args:\n            prompt_id: The ID of the prompt to fetch\n\n        Returns:\n            The prompt data from the API\n\n        Raises:\n            Exception: If the API request fails\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            **(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:","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/integrations/generic_prompt_management/generic_prompt_manager.py#L91-L127","documentation":"GenericPromptManager.fetch_prompt_from_api raises ValueError when both prompt_id and prompt_spec are None. The manager cannot build a query without at least one identifier: prompt_id addresses an existing prompt on the API, while prompt_spec (a structured spec object) is the alternative. This check is repeated in the async variant.","triggerScenarios":"Calling fetch_prompt_from_api(None, None) directly; a completion routed through generic prompt management whose litellm_params carried neither prompt_id nor a usable prompt_spec; prompt_id stripped/renamed by an upstream serializer so it arrives as None.","commonSituations":"Custom proxy code that fetches prompts programmatically and assumes a default; model strings like 'litellm_proxy/<prompt_id>' with an empty ID segment; fields dropped because they weren't declared in a pydantic model.","solutions":["Pass a prompt_id: fetch_prompt_from_api('pm-123', None).","Or pass a prompt_spec object when you don't have a server-side ID.","When routing via model names, ensure the prompt ID is actually present: model='litellm_proxy/pm-123'.","Log litellm_params before the call to see which identifier is getting lost."],"exampleFix":"# before\nmanager.fetch_prompt_from_api(prompt_id=None, prompt_spec=None)  # ValueError\n\n# after\nmanager.fetch_prompt_from_api(prompt_id='pm-123', prompt_spec=None)","handlingStrategy":"validation","validationCode":"if prompt_id is None and prompt_spec is None:\n    raise ValueError('Cannot fetch prompt: provide prompt_id or prompt_spec')","typeGuard":"def has_prompt_identifier(prompt_id: str | None, prompt_spec: object | None) -> bool:\n    return prompt_id is not None or prompt_spec is not None","tryCatchPattern":"try:\n    data = manager.fetch_prompt_from_api(prompt_id, prompt_spec)\nexcept ValueError as e:\n    if 'prompt_id or prompt_spec' in str(e):\n        raise ConfigError('Prompt request missing prompt_id/prompt_spec') from e\n    raise","preventionTips":["Assert an identifier exists before calling fetch; never call it 'just to see'.","When routing by model string, ensure the prompt ID segment is non-empty."],"tags":["prompt-management","parameter-validation"],"backgroundTag":"missing-required-argument","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}