BerriAI/litellm · error · HTTPException
litellm_params.api_base is required for generic_guardrail_ap
Error message
litellm_params.api_base is required for generic_guardrail_api
What it means
Registering a generic_guardrail_api guardrail requires litellm_params.api_base (the external guardrail service URL); registration is refused 400 without it since the hook would have nothing to POST to.
Source
Thrown at litellm/proxy/guardrails/guardrail_endpoints.py:730
# Validate team membership for non-admin users when team differs from key
is_admin: Final = user_api_key_dict.user_role == LitellmUserRoles.PROXY_ADMIN
if not is_admin and team_id != user_api_key_dict.team_id:
user_team_ids: Final = await _get_user_team_ids(user_api_key_dict)
if team_id not in user_team_ids:
raise HTTPException(
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,View on GitHub (pinned to 77b7c6c40c)
Solutions
- Set litellm_params.api_base in the guardrail config for generic_guardrail_api.
Example fix
litellm_params: api_base: https://guardrail.example.com
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at litellm/proxy/guardrails/guardrail_endpoints.py:730 when the library encounters an invalid state.
Common situations: A generic_guardrail_api guardrail was configured without api_base.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/5d281b5aed07b409.
Report an issue: GitHub.