BerriAI/litellm · error · HTTPException

You are not authorized to access this prompt. Your role - {u

Error message

You are not authorized to access this prompt. Your role - {user_api_key_dict.user_role}, Your key's prompts - {prompts}

What it means

Authorization failure on prompt fetch: the key's metadata restricts access to a list of allowed prompt IDs and the requested prompt_id is not in it, so the caller is refused with their role and allowed list echoed.

Source

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

            "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
    # If prompt_id has a version suffix (e.g., "testprompt.v2"), fetch that specific version
    # Otherwise fetch the latest version in that environment

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Use a key whose allowed prompts include this prompt, or a proxy admin key.
  2. Ask an admin to grant the key/role access to the prompt.
Defensive patterns

Strategy: validation

When it happens

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