BerriAI/litellm · error · HTTPException

Prompt not found

Error message

Prompt {prompt_id} not found

What it means

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.

Solutions

  1. List prompts to confirm the prompt_id; it may have been deleted or never created.
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at litellm/proxy/prompts/prompt_endpoints.py:639 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/15d2275507d858c5. Report an issue: GitHub.

Appendix: source

Thrown at litellm/proxy/prompts/prompt_endpoints.py:639

        },
        "prompt_info": {
            "prompt_type": "config"
        },
        "created_at": "2023-11-09T12:34:56.789Z",
        "updated_at": "2023-11-09T12:34:56.789Z",
        "content": "System: You are a helpful assistant.\n\nUser: {{user_message}}"
    }
    ```
    """
    from litellm.proxy.prompts.prompt_registry import IN_MEMORY_PROMPT_REGISTRY
    from litellm.proxy.proxy_server import prisma_client

    ## CHECK IF USER HAS ACCESS TO PROMPT
    prompts: list[str] | None = None
    if user_api_key_dict.metadata is not None:
        prompts = cast(list[str] | None, user_api_key_dict.metadata.get("prompts", None))
        if prompts is not None and prompt_id not in prompts:
            raise HTTPException(status_code=400, detail=f"Prompt {prompt_id} not found")
    if not user_api_key_has_admin_view(user_api_key_dict):
        raise HTTPException(
            status_code=403,
            detail=f"You are not authorized to access this prompt. Your role - {user_api_key_dict.user_role}, Your key's prompts - {prompts}",
        )

    base_prompt_id: Final = get_base_prompt_id(prompt_id=prompt_id)

    # Query all environments this prompt exists in (lightweight: distinct on environment)
    all_environments: list[str] = []
    if prisma_client is not None:
        all_prompt_rows: Final = await _prompt_table(prisma_client).find_many(
            where={"prompt_id": base_prompt_id},
            distinct=["environment"],
        )
        all_environments = sorted(set(row.environment for row in all_prompt_rows if row.environment))

    # If environment is specified, find the version in that environment from DB

View on GitHub (pinned to 77b7c6c40c)