BerriAI/litellm · error · HTTPException

litellm_params.api_base must use http or https scheme

Error message

litellm_params.api_base must use http or https scheme

What it means

Raised in the generic-guardrail registration handler when litellm_params.api_base parses with a scheme other than http/https (e.g. a bare host, websocket, or file URL). The guardrail will be called over HTTP, so the base URL must be an absolute web URL; this is the scheme-stage check — an earlier sibling verifies presence, the next one verifies hostname.

Source

Thrown at litellm/proxy/guardrails/guardrail_endpoints.py:736

                status_code=403,
                detail=f"You are not a member of team {team_id!r}",
            )

    params: Final = request.get_litellm_params_dict()
    if params.get("guardrail") != GENERIC_GUARDRAIL_API:
        raise HTTPException(
            status_code=400,
            detail=f"Only guardrails with litellm_params.guardrail={GENERIC_GUARDRAIL_API!r} are accepted for registration",
        )
    api_base: Final = params.get("api_base")
    if not api_base:
        raise HTTPException(
            status_code=400,
            detail="litellm_params.api_base is required for generic_guardrail_api",
        )
    parsed: Final = urlparse(api_base)
    if parsed.scheme not in ("http", "https"):
        raise HTTPException(
            status_code=400,
            detail="litellm_params.api_base must use http or https scheme",
        )
    if not parsed.hostname:
        raise HTTPException(
            status_code=400,
            detail="litellm_params.api_base must contain a valid hostname",
        )
    mode: Final = params.get("mode")
    if mode is None:
        raise HTTPException(
            status_code=400,
            detail="litellm_params.mode is required (e.g. pre_call, post_call)",
        )

    try:
        existing = await _guardrails_table(prisma_client).find_unique(where={"guardrail_name": request.guardrail_name})
        if existing is not None:

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Use an http:// or https:// URL for litellm_params.api_base.

Example fix

api_base: https://guardrail.example.com
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/proxy/guardrails/guardrail_endpoints.py:736 when the library encounters an invalid state.

Common situations: The guardrail api_base uses a non-HTTP scheme.


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