{"record":{"id":"15d2275507d858c5","repo":"BerriAI/litellm","slug":"prompt-prompt-id-not-found","errorCode":null,"errorMessage":"Prompt {prompt_id} not found","messagePattern":"Prompt (.+?) not found","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"litellm/proxy/prompts/prompt_endpoints.py","lineNumber":639,"sourceCode":"        },\n        \"prompt_info\": {\n            \"prompt_type\": \"config\"\n        },\n        \"created_at\": \"2023-11-09T12:34:56.789Z\",\n        \"updated_at\": \"2023-11-09T12:34:56.789Z\",\n        \"content\": \"System: You are a helpful assistant.\\n\\nUser: {{user_message}}\"\n    }\n    ```\n    \"\"\"\n    from litellm.proxy.prompts.prompt_registry import IN_MEMORY_PROMPT_REGISTRY\n    from litellm.proxy.proxy_server import prisma_client\n\n    ## CHECK IF USER HAS ACCESS TO PROMPT\n    prompts: list[str] | None = None\n    if user_api_key_dict.metadata is not None:\n        prompts = cast(list[str] | None, user_api_key_dict.metadata.get(\"prompts\", None))\n        if prompts is not None and prompt_id not in prompts:\n            raise HTTPException(status_code=400, detail=f\"Prompt {prompt_id} not found\")\n    if not user_api_key_has_admin_view(user_api_key_dict):\n        raise HTTPException(\n            status_code=403,\n            detail=f\"You are not authorized to access this prompt. Your role - {user_api_key_dict.user_role}, Your key's prompts - {prompts}\",\n        )\n\n    base_prompt_id: Final = get_base_prompt_id(prompt_id=prompt_id)\n\n    # Query all environments this prompt exists in (lightweight: distinct on environment)\n    all_environments: list[str] = []\n    if prisma_client is not None:\n        all_prompt_rows: Final = await _prompt_table(prisma_client).find_many(\n            where={\"prompt_id\": base_prompt_id},\n            distinct=[\"environment\"],\n        )\n        all_environments = sorted(set(row.environment for row in all_prompt_rows if row.environment))\n\n    # If environment is specified, find the version in that environment from DB","sourceCodeStart":621,"sourceCodeEnd":657,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/prompts/prompt_endpoints.py#L621-L657","documentation":"404 guard when fetching a prompt: neither the DB nor the in-memory registry (including latest-version resolution) contains a prompt with the given prompt_id, or the caller's key metadata restricts them from it.","triggerScenarios":"Thrown at litellm/proxy/prompts/prompt_endpoints.py:639 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["List prompts to confirm the prompt_id; it may have been deleted or never created."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}