{"record":{"id":"61b29b3df3df6e32","repo":"BerriAI/litellm","slug":"prompt-id-is-required-for-langfuse-prompt-manageme","errorCode":null,"errorMessage":"prompt_id is required for Langfuse prompt management","messagePattern":"prompt_id is required for Langfuse prompt management","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/langfuse/langfuse_prompt_management.py","lineNumber":243,"sourceCode":"            allow_env_credentials=dynamic_callback_params.get(\"langfuse_host\") is None,\n        )\n        langfuse_prompt_client: Final = self._get_prompt_from_id(\n            langfuse_prompt_id=prompt_id,\n            langfuse_client=langfuse_client,\n        )\n        return langfuse_prompt_client is not None\n\n    def _compile_prompt_helper(\n        self,\n        prompt_id: str | None,\n        prompt_spec: PromptSpec | None,\n        prompt_variables: dict | None,\n        dynamic_callback_params: StandardCallbackDynamicParams,\n        prompt_label: str | None = None,\n        prompt_version: int | None = None,\n    ) -> PromptManagementClient:\n        if prompt_id is None:\n            raise ValueError(\"prompt_id is required for Langfuse prompt management\")\n\n        langfuse_client: Final = langfuse_client_init(\n            langfuse_public_key=dynamic_callback_params.get(\"langfuse_public_key\"),\n            langfuse_secret=dynamic_callback_params.get(\"langfuse_secret\"),\n            langfuse_secret_key=dynamic_callback_params.get(\"langfuse_secret_key\"),\n            langfuse_host=dynamic_callback_params.get(\"langfuse_host\"),\n            allow_env_credentials=dynamic_callback_params.get(\"langfuse_host\") is None,\n        )\n        langfuse_prompt_client: Final = self._get_prompt_from_id(\n            langfuse_prompt_id=prompt_id,\n            langfuse_client=langfuse_client,\n            prompt_label=prompt_label,\n            prompt_version=prompt_version,\n        )\n\n        ## SET PROMPT\n        compiled_prompt: Final = self._compile_prompt(\n            langfuse_prompt_client=langfuse_prompt_client,","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/integrations/langfuse/langfuse_prompt_management.py#L225-L261","documentation":"The Langfuse prompt-management client requires a concrete prompt identifier: _compile_prompt_helper raises ValueError when prompt_id is None. LiteLLM passes prompt_id from the callback parameters or the PromptSpec; if you enable Langfuse prompt management but never name a prompt, there is nothing to fetch from Langfuse, so this fails fast.","triggerScenarios":"Configuring litellm.prompt_manager = 'langfuse' without supplying prompt_id in the request/callback params (e.g. no langfuse_prompt_id in dynamic callback params or litellm_params); building a PromptSpec whose prompt_id field is left null; calling completion with prompt variables but no prompt id.","commonSituations":"Copy-pasting a Langfuse prompt-management config that omits the prompt name; assuming the prompt is inferred from the model or messages; typos in the callback param key (e.g. langfuse_prompt_label set but prompt_id forgotten).","solutions":["Pass the prompt id: add langfuse_prompt_id to callback params / metadata, or the documented prompt_params carrying prompt_id","Check for typos in the parameter name that carries the prompt id","Optionally also pass prompt_label/prompt_version to pin a specific variant","If you meant to send a raw prompt (not a managed one), remove the Langfuse prompt manager from the call"],"exampleFix":"# before\nresponse = litellm.completion(\n    model=\"gpt-4o\",\n    messages=[{\"role\": \"user\", \"content\": \"...\"}],\n    metadata={\"prompt_management\": \"langfuse\"},  # ValueError: prompt_id is required\n)\n\n# after\nresponse = litellm.completion(\n    model=\"gpt-4o\",\n    messages=[{\"role\": \"user\", \"content\": \"...\"}],\n    metadata={\"prompt_management\": \"langfuse\", \"prompt_id\": \"my-chat-prompt\"},\n)","handlingStrategy":"validation","validationCode":"def validate_prompt_call(metadata: dict) -> None:\n    if metadata.get(\"prompt_management\") == \"langfuse\" and not metadata.get(\"prompt_id\"):\n        raise ValueError(\"langfuse prompt management requires prompt_id\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Centralize prompt-call construction in one helper that always sets prompt_id","Fail fast on missing prompt_id in request-building code, before litellm is invoked"],"tags":["python","langfuse","prompt-management","validation"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}