{"record":{"id":"5d281b5aed07b409","repo":"BerriAI/litellm","slug":"litellm-params-api-base-is-required-for-generic-gu","errorCode":null,"errorMessage":"litellm_params.api_base is required for generic_guardrail_api","messagePattern":"litellm_params\\.api_base is required for generic_guardrail_api","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"litellm/proxy/guardrails/guardrail_endpoints.py","lineNumber":730,"sourceCode":"    # Validate team membership for non-admin users when team differs from key\n    is_admin: Final = user_api_key_dict.user_role == LitellmUserRoles.PROXY_ADMIN\n    if not is_admin and team_id != user_api_key_dict.team_id:\n        user_team_ids: Final = await _get_user_team_ids(user_api_key_dict)\n        if team_id not in user_team_ids:\n            raise HTTPException(\n                status_code=403,\n                detail=f\"You are not a member of team {team_id!r}\",\n            )\n\n    params: Final = request.get_litellm_params_dict()\n    if params.get(\"guardrail\") != GENERIC_GUARDRAIL_API:\n        raise HTTPException(\n            status_code=400,\n            detail=f\"Only guardrails with litellm_params.guardrail={GENERIC_GUARDRAIL_API!r} are accepted for registration\",\n        )\n    api_base: Final = params.get(\"api_base\")\n    if not api_base:\n        raise HTTPException(\n            status_code=400,\n            detail=\"litellm_params.api_base is required for generic_guardrail_api\",\n        )\n    parsed: Final = urlparse(api_base)\n    if parsed.scheme not in (\"http\", \"https\"):\n        raise HTTPException(\n            status_code=400,\n            detail=\"litellm_params.api_base must use http or https scheme\",\n        )\n    if not parsed.hostname:\n        raise HTTPException(\n            status_code=400,\n            detail=\"litellm_params.api_base must contain a valid hostname\",\n        )\n    mode: Final = params.get(\"mode\")\n    if mode is None:\n        raise HTTPException(\n            status_code=400,","sourceCodeStart":712,"sourceCodeEnd":748,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/guardrails/guardrail_endpoints.py#L712-L748","documentation":"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.","triggerScenarios":"Thrown at litellm/proxy/guardrails/guardrail_endpoints.py:730 when the library encounters an invalid state.","commonSituations":"A generic_guardrail_api guardrail was configured without api_base.","solutions":["Set litellm_params.api_base in the guardrail config for generic_guardrail_api."],"exampleFix":"litellm_params:\n  api_base: https://guardrail.example.com","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}