BerriAI/litellm · error · ValueError
SemanticGuard: custom routes file not found: {file_path}
Error message
SemanticGuard: custom routes file not found: {file_path} What it means
Error "SemanticGuard: custom routes file not found: {file_path}" thrown in BerriAI/litellm.
Source
Thrown at litellm/proxy/guardrails/guardrail_hooks/semantic_guard/route_loader.py:55
)
with open(file_path, "r") as f:
return yaml.safe_load(f)
@staticmethod
def list_builtin_templates() -> list[str]:
"""List available built-in template names."""
templates: Final = []
if os.path.isdir(ROUTE_TEMPLATES_DIR):
for fname in os.listdir(ROUTE_TEMPLATES_DIR):
if fname.endswith(".yaml"):
templates.append(fname.replace(".yaml", ""))
return sorted(templates)
@staticmethod
def load_custom_routes_file(file_path: str) -> list[dict[str, Any]]:
"""Load custom routes from a YAML file."""
if not os.path.exists(file_path):
raise ValueError(f"SemanticGuard: custom routes file not found: {file_path}")
with open(file_path, "r") as f:
data: Final = yaml.safe_load(f)
if isinstance(data, list):
return data
if isinstance(data, dict):
return [data]
raise ValueError(f"SemanticGuard: invalid custom routes file format in {file_path}")
@classmethod
def build_routes(
cls,
route_templates: list[str] | None,
custom_routes_file: str | None,
custom_routes: list[dict[str, Any]] | None,
global_threshold: float = DEFAULT_SEMANTIC_GUARD_SIMILARITY_THRESHOLD,
) -> list["Route"]:
"""Build semantic-router Route objects from templates + custom config."""
from semantic_router.routers.base import RouteView on GitHub (pinned to 77b7c6c40c)
Solutions
- Verify the custom routes file_path exists and is readable by the proxy process.
- Use an absolute path or a path relative to the proxy working directory.
When it happens
Trigger: Thrown at litellm/proxy/guardrails/guardrail_hooks/semantic_guard/route_loader.py:55 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/2c93eeb10981e6f3.
Report an issue: GitHub.