BerriAI/litellm · error · Exception
File not found. file_path={file_path}
Error message
File not found. file_path={file_path} What it means
Exception raised in _ENTERPRISE_LlamaGuard.__init__ when litellm.llamaguard_unsafe_content_categories points to a file path that does not exist. This optional file defines which LlamaGuard safety categories to enforce (S1–S13 etc.); when configured, the hook must be able to read it at init time.
Source
Thrown at enterprise/litellm_enterprise/enterprise_callbacks/llama_guard.py:44
from litellm.types.utils import CallTypesLiteral, Choices, ModelResponse
class _ENTERPRISE_LlamaGuard(CustomLogger):
# Class variables or attributes
def __init__(self, model_name: Optional[str] = None):
_model = model_name or litellm.llamaguard_model_name
if _model is None:
raise ValueError("model_name not set for LlamaGuard")
self.model = _model
file_path = litellm.llamaguard_unsafe_content_categories
data = None
if file_path is not None:
try:
with open(file_path, "r") as file:
data = file.read()
except FileNotFoundError:
raise Exception(f"File not found. file_path={file_path}")
except Exception as e:
raise Exception(f"An error occurred: {str(e)}, file_path={file_path}")
self.unsafe_content_categories = data
verbose_proxy_logger.debug(
f"self.unsafe_content_categories: {self.unsafe_content_categories}"
)
def print_verbose(self, print_statement):
try:
verbose_proxy_logger.debug(print_statement)
if litellm.set_verbose:
print(print_statement) # noqa
except Exception:
pass
def set_custom_prompt_template(self, messages: list):View on GitHub (pinned to 6c2dcb801b)
Solutions
- Create the file at the configured path with the LlamaGuard category definitions (one category token per line, e.g. S1..S13 subset).
- Use an absolute path to avoid CWD-dependent resolution.
- In Docker, COPY/mount the categories file and reference the mounted path.
- If you want all categories enforced by default, unset llamaguard_unsafe_content_categories entirely (the hook skips file loading when it is None).
Example fix
# before litellm_settings: llamaguard_unsafe_content_categories: ./unsafe_categories.txt # missing # after litellm_settings: llamaguard_unsafe_content_categories: /etc/litellm/unsafe_categories.txt # or remove the setting to use defaults
Defensive patterns
Strategy: validation
Validate before calling
import os
cats = os.environ.get("LLAMAGUARD_UNSAFE_CONTENT_CATEGORIES_FILE")
if cats and not os.path.isfile(cats):
raise SystemExit(f"unsafe categories file missing: {cats}") Try / catch
try:
guard = _ENTERPRISE_LlamaGuard(model_name=name)
except Exception as e:
if "File not found" in str(e):
logger.error("create the categories file or unset llamaguard_unsafe_content_categories")
raise Prevention
- Use an absolute path for llamaguard_unsafe_content_categories.
- Ship the categories file inside the image (COPY) rather than assuming CWD.
- Unset the setting entirely to use LlamaGuard defaults when a custom subset is unnecessary.
- Validate the file exists in a startup probe.
When it happens
Trigger: Setting llamaguard_unsafe_content_categories: "./unsafe_categories.txt" in litellm settings where the file is missing, the relative path resolves against a different working directory, or the container image lacks the file.
Common situations: Following LlamaGuard docs that reference a categories file without creating/mounting it; moving the proxy's working directory so relative paths break; forgetting to COPY the file into a Docker image.
Related errors
- File not found. blocked_user_list={blocked_user_list}
- model_name not set for LlamaGuard
- An error occurred: {str(e)}, file_path={file_path}
- An error occurred: {str(e)}, blocked_user_list={blocked_user
- Missing `LLM_GUARD_API_BASE` from environment
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/d061a1bc0e4905c9.
Report an issue: GitHub.