BerriAI/litellm · error · Exception
File not found. banned_keywords_list={banned_keywords_list}
Error message
File not found. banned_keywords_list={banned_keywords_list} What it means
In the OpenAI image-variations handler, the async preparation step (transforming the request via the provider transformation layer) is wrapped in a catch-all: any exception raised while building the request (param validation errors like 'Parameter ... is not supported', encoding failures of the input image, invalid API base) is re-raised as OpenAIError with the upstream status_code (default 500), headers, and text. The literal 'error_text' means the original exception had no .text attribute, so str(e) was used - the real cause is in the wrapped message.
Source
Thrown at enterprise/enterprise_hooks/banned_keywords.py:42
# Class variables or attributes
def __init__(self):
banned_keywords_list = litellm.banned_keywords_list
if banned_keywords_list is None:
raise Exception(
"`banned_keywords_list` can either be a list or filepath. None set."
)
if isinstance(banned_keywords_list, list):
self.banned_keywords_list = banned_keywords_list
if isinstance(banned_keywords_list, str): # assume it's a filepath
try:
with open(banned_keywords_list, "r") as file:
data = file.read()
self.banned_keywords_list = data.split("\n")
except FileNotFoundError:
raise Exception(
f"File not found. banned_keywords_list={banned_keywords_list}"
)
except Exception as e:
raise Exception(
f"An error occurred: {str(e)}, banned_keywords_list={banned_keywords_list}"
)
def print_verbose(self, print_statement, level: Literal["INFO", "DEBUG"] = "DEBUG"):
if level == "INFO":
verbose_proxy_logger.info(print_statement)
elif level == "DEBUG":
verbose_proxy_logger.debug(print_statement)
if litellm.set_verbose is True:
print(print_statement) # noqa
def test_violation(self, test_str: str):
for word in self.banned_keywords_list:View on GitHub (pinned to 6c2dcb801b)
Solutions
- Catch OpenAIError and read .message - it contains the underlying transformation exception text.
- Remove unsupported params or set drop_params=True.
- Verify the input image is a valid, readable PNG and the model supports variations (dall-e-2).
- Upgrade litellm if the transformation layer changed for your model.
Example fix
# before
img = await litellm.aimage_variations(model="dall-e-2", image=open("cat.png","rb"), n=2)
# after
try:
img = await litellm.aimage_variations(model="dall-e-2", image=open("cat.png","rb"), n=2)
except litellm.exceptions.OpenAIError as e:
logger.error("image_variations failed: %s", e.message)
raise Defensive patterns
Strategy: try-catch
Validate before calling
from pathlib import Path
def variation_input_ok(path: str) -> bool:
p = Path(path)
return p.exists() and p.stat().st_size > 0 and p.read_bytes()[:8] == b"\x89PNG\r\n\x1a\n" Type guard
from litellm.exceptions import OpenAIError
def is_transform_layer_error(e: BaseException) -> bool:
return isinstance(e, OpenAIError) and getattr(e, "status_code", 500) == 500 and e.headers is None Try / catch
from litellm.exceptions import OpenAIError
try:
img = await litellm.aimage_variations(model="dall-e-2", image=image_bytes, n=2)
except OpenAIError as e:
logger.error("image_variations failed: %s", e.message) # e.message holds the transform-layer cause
raise Prevention
- Verify the input image is a valid PNG before calling (dall-e-2 variations require PNG).
- Pass only params the model supports; prefer drop_params=True for user-driven param dicts.
- Log e.message fully - the underlying ValueError text is nested inside the OpenAIError.
When it happens
Trigger: Calling litellm.image_variations() (async path) with an unsupported parameter for the model (which raises in transformation), a corrupted or wrong-format image file, an unwritable/missing api_base, or missing credentials that surface during request preparation rather than the HTTP call.
Common situations: Generating variations of dall-e-2 images with dall-e-3-only params; passing PNG bytes where the API expects a valid image the encoder can process; mismatched model names routed to the image_variations endpoint; transformation-layer version drift after litellm upgrades.
Related errors
- No Braintrust API token provided. Pass via Authorization hea
- Unclassified keys in {PRICES_PATH.name}: {', '.join(unclassi
- Unknown hook: {hook_name}. Available hooks: {list(ENTERPRISE
- Braintrust API error: {e.response.text}
- Failed to connect to Braintrust API: {str(e)}
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/612ff331cd08e9d3.
Report an issue: GitHub.