BerriAI/litellm · error · HTTPException

Prompt with ID {prompt_id} not found

Error message

Prompt with ID {prompt_id} not found

What it means

Delete guard: the prompt ID (after direct lookup and latest-version fallback in the in-memory registry and DB) resolves to no existing prompt, so there is nothing to delete; surfaced as 404.

Source

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

    if prisma_client is None:
        raise HTTPException(status_code=500, detail=CommonProxyErrors.db_not_connected_error.value)

    try:
        # Try to get prompt directly first
        existing_prompt = IN_MEMORY_PROMPT_REGISTRY.get_prompt_by_id(prompt_id)

        # If not found, try to find the latest version
        if existing_prompt is None:
            latest_prompt_id: Final = get_latest_version_prompt_id(
                prompt_id=prompt_id,
                all_prompt_ids=IN_MEMORY_PROMPT_REGISTRY.IN_MEMORY_PROMPTS,
            )
            existing_prompt = IN_MEMORY_PROMPT_REGISTRY.get_prompt_by_id(latest_prompt_id)
            # Use the resolved prompt_id for deletion
            prompt_id = latest_prompt_id

        if existing_prompt is None:
            raise HTTPException(status_code=404, detail=f"Prompt with ID {prompt_id} not found")

        if existing_prompt.prompt_info.prompt_type == "config":
            raise HTTPException(
                status_code=400,
                detail="Cannot delete config prompts.",
            )

        # Get the base prompt ID (without version suffix) for database deletion
        base_prompt_id: Final = get_base_prompt_id(prompt_id=prompt_id)

        # Build delete filter; scope to environment if provided
        delete_where: Final[dict[str, str]] = {"prompt_id": base_prompt_id}
        if environment:
            delete_where["environment"] = environment

        # Delete versions from the database (scoped to environment if provided)
        await _prompt_table(prisma_client).delete_many(where=delete_where)

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Confirm the prompt_id via the prompts list endpoint; recreate the prompt if deleted.
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at litellm/proxy/prompts/prompt_endpoints.py:985 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/0eb363ab87bba2f5. Report an issue: GitHub.