{"record":{"id":"30b25aeb93677eda","repo":"BerriAI/litellm","slug":"litellm-params-api-base-must-contain-a-valid-hostn","errorCode":null,"errorMessage":"litellm_params.api_base must contain a valid hostname","messagePattern":"litellm_params\\.api_base must contain a valid hostname","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"litellm/proxy/guardrails/guardrail_endpoints.py","lineNumber":741,"sourceCode":"    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,\n            detail=\"litellm_params.mode is required (e.g. pre_call, post_call)\",\n        )\n\n    try:\n        existing = await _guardrails_table(prisma_client).find_unique(where={\"guardrail_name\": request.guardrail_name})\n        if existing is not None:\n            raise HTTPException(\n                status_code=400,\n                detail=f\"Guardrail with name {request.guardrail_name!r} already exists\",\n            )\n    except HTTPException:","sourceCodeStart":723,"sourceCodeEnd":759,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/guardrails/guardrail_endpoints.py#L723-L759","documentation":"Raised in the generic-guardrail registration handler when the parsed api_base has no hostname (e.g. 'https:///path' or a scheme-only string). The guardrail needs a reachable host to POST hooks to; this is the hostname stage of the api_base validation ladder that checks presence, then scheme, then hostname, then mode.","triggerScenarios":"Thrown at litellm/proxy/guardrails/guardrail_endpoints.py:741 when the library encounters an invalid state.","commonSituations":"The guardrail api_base URL lacks a hostname.","solutions":["Provide an api_base that includes a valid hostname."],"exampleFix":"api_base: https://guardrail.example.com/v1","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"}