BerriAI/litellm · warning · Exception

`banned_keywords_list` can either be a list or filepath. Non

Error message

`banned_keywords_list` can either be a list or filepath. None set.

What it means

Parameter validation for GPT-image models (gpt-image-1) image generation: before the request is sent, non-default params are checked against the model's supported OpenAI params; anything outside that set raises ValueError with the supported list unless drop_params=True. GPT-image models accept the newer parameter set (background, moderation, output_format, quality, etc.) but reject legacy dall-e params like style, or chat params like temperature.

Source

Thrown at enterprise/enterprise_hooks/banned_keywords.py:29

import litellm
from litellm.caching.caching import DualCache
from litellm.proxy._types import UserAPIKeyAuth
from litellm.proxy.guardrails._content_utils import (
    is_text_content_call_type,
    iter_message_text,
)
from litellm.integrations.custom_logger import CustomLogger
from litellm._logging import verbose_proxy_logger
from fastapi import HTTPException


class _ENTERPRISE_BannedKeywords(CustomLogger):
    # 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}"

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Use only the supported params reported in the error (for gpt-image-1: n, size, quality, background, output_format, output_compression, moderation, user, partial_images).
  2. Set drop_params=True to drop legacy params automatically.
  3. Remove response_format handling - gpt-image-1 returns base64 by default.
  4. Build per-model param dicts instead of one shared dict.

Example fix

# before
litellm.image_generation(model="gpt-image-1", prompt="cat", style="natural", response_format="b64_json")

# after
litellm.image_generation(model="gpt-image-1", prompt="cat", background="transparent")
# or: litellm.drop_params = True
Defensive patterns

Strategy: validation

Validate before calling

GPT_IMAGE_SUPPORTED = {"prompt", "n", "size", "quality", "background", "output_format", "output_compression", "moderation", "user", "partial_images"}

def validate_gpt_image_params(params: dict) -> list[str]:
    return [k for k in params if k not in GPT_IMAGE_SUPPORTED and k != "prompt"]  # non-empty => will raise

Type guard

def param_set_is_supported(params: dict, supported: set[str]) -> bool:
    return set(params).issubset(supported)

Try / catch

try:
    img = litellm.image_generation(model="gpt-image-1", prompt=p, **params)
except ValueError as e:
    if "not supported" in str(e):
        params = {k: v for k, v in params.items() if k in GPT_IMAGE_SUPPORTED}
        img = litellm.image_generation(model="gpt-image-1", prompt=p, **params)
    else:
        raise

Prevention

When it happens

Trigger: Calling litellm.image_generation(model='gpt-image-1', ...) with style='natural' (dall-e-3-only), response_format (not supported on gpt-image-1), or any other param outside its supported list, without drop_params=True.

Common situations: Reusing dall-e-2/3 parameter blocks for gpt-image-1; passing response_format='b64_json' out of habit (gpt-image always returns b64); generic wrappers forwarding full kwargs; model routers applying shared default params.

Related errors


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/8a1fe4afbd8e4626. Report an issue: GitHub.