BerriAI/litellm · error · HTTPException

Cannot delete config prompts.

Error message

Cannot delete config prompts.

What it means

Mutation guard on prompt deletion: the prompt exists but is defined in the proxy config file, not the database. Deleting it via the API would be overwritten on the next config reload, so deletion is refused; edit the config file instead.

Source

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

    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)

        # Remove matching prompts from memory — scope to environment if provided
        if environment:
            prompts_to_delete: Final = [

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Remove the prompt from config.yaml and restart instead of deleting via the API; config prompts cannot be deleted at runtime.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/proxy/prompts/prompt_endpoints.py:988 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/05b546a9caf2d93b. Report an issue: GitHub.