{"record":{"id":"71f36abda425f246","repo":"BerriAI/litellm","slug":"prompt-id-is-required-for-prompt-management-base-c","errorCode":null,"errorMessage":"prompt_id is required for Prompt Management Base class","messagePattern":"prompt_id is required for Prompt Management Base class","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/prompt_management_base.py","lineNumber":168,"sourceCode":"\n        return model, completed_messages, updated_non_default_params\n\n    def get_chat_completion_prompt(\n        self,\n        model: str,\n        messages: list[AllMessageValues],\n        non_default_params: dict,\n        prompt_id: str | None,\n        prompt_variables: dict | None,\n        dynamic_callback_params: StandardCallbackDynamicParams,\n        prompt_spec: PromptSpec | None = None,\n        prompt_label: str | None = None,\n        prompt_version: int | None = None,\n        ignore_prompt_manager_model: bool | None = False,\n        ignore_prompt_manager_optional_params: bool | None = False,\n    ) -> tuple[str, list[AllMessageValues], dict]:\n        if prompt_id is None:\n            raise ValueError(\"prompt_id is required for Prompt Management Base class\")\n        if not self.should_run_prompt_management(\n            prompt_id=prompt_id,\n            prompt_spec=prompt_spec,\n            dynamic_callback_params=dynamic_callback_params,\n        ):\n            return model, messages, non_default_params\n\n        prompt_template: Final = self.compile_prompt(\n            prompt_id=prompt_id,\n            prompt_variables=prompt_variables,\n            client_messages=messages,\n            dynamic_callback_params=dynamic_callback_params,\n            prompt_label=prompt_label,\n            prompt_version=prompt_version,\n        )\n\n        return self.post_compile_prompt_processing(\n            prompt_template=prompt_template,","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/integrations/prompt_management_base.py#L150-L186","documentation":"PromptManagementBase.add_prompt_management_to_request is the hook that expands a model alias like 'promptlayer/<prompt_id>' into full messages. If prompt_id resolves to None (no id in the model string, no prompt_spec, no default on the callback), it raises ValueError immediately — there is nothing to compile.","triggerScenarios":"Routing a request to a prompt-management integration without an id: model='promptlayer/' (empty id), a callback subclass with no initial/default prompt id, or a code path that calls add_prompt_management_to_request(prompt_id=None) directly.","commonSituations":"Typos in the model alias; registering a custom prompt-management callback but forgetting to set its default prompt id; renaming prompts in the manager so the alias no longer parses.","solutions":["Pass a concrete prompt id in the model string, e.g. litellm.completion(model=\"promptlayer/<your-prompt-id>\", ...)","If using a custom PromptManagementBase subclass, set the default prompt id (e.g. self.prompt_id in __init__ or via dynamic_callback_params)","If the request should not use prompt management, route it to a plain model name without the integration prefix"],"exampleFix":"# before\nresponse = litellm.completion(model=\"promptlayer/\", messages=messages)\n# ValueError: prompt_id is required for Prompt Management Base class\n\n# after\nresponse = litellm.completion(model=\"promptlayer/1729\", messages=messages)","handlingStrategy":"validation","validationCode":"import re\n\ndef prompt_id_from_model(model: str) -> str | None:\n    m = re.match(r\"^(promptlayer|anthropic_prompt|promptforge)/(.+)$\", model)\n    return m.group(2) if m and m.group(2) else None\n\nassert prompt_id_from_model(requested_model), \"model alias must include a prompt id\"","typeGuard":"from typing import TypeGuard\n\ndef has_prompt_id(prompt_id: str | None) -> TypeGuard[str]:\n    return isinstance(prompt_id, str) and prompt_id.strip() != \"\"","tryCatchPattern":"try:\n    model, messages, params = pm.add_prompt_management_to_request(\n        model, messages, non_default_params, prompt_id, prompt_variables, {}\n    )\nexcept ValueError as e:\n    if \"prompt_id is required\" in str(e):\n        raise ValueError(f\"Model '{model}' needs a prompt id, e.g. promptlayer/<id>\") from e\n    raise","preventionTips":["Encode the prompt id in the model alias at config time and lint aliases for a non-empty id segment","Give custom PromptManagementBase subclasses a default prompt id if they are always bound to one prompt","Route non-prompt traffic to plain model names so the prompt-management hook never sees prompt_id=None"],"tags":["prompt-management","model-alias","configuration"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}