{"record":{"id":"8a1fe4afbd8e4626","repo":"BerriAI/litellm","slug":"banned-keywords-list-can-either-be-a-list-or-fil","errorCode":null,"errorMessage":"`banned_keywords_list` can either be a list or filepath. None set.","messagePattern":"`banned_keywords_list` can either be a list or filepath\\. None set\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"warning","filePath":"enterprise/enterprise_hooks/banned_keywords.py","lineNumber":29,"sourceCode":"import litellm\nfrom litellm.caching.caching import DualCache\nfrom litellm.proxy._types import UserAPIKeyAuth\nfrom litellm.proxy.guardrails._content_utils import (\n    is_text_content_call_type,\n    iter_message_text,\n)\nfrom litellm.integrations.custom_logger import CustomLogger\nfrom litellm._logging import verbose_proxy_logger\nfrom fastapi import HTTPException\n\n\nclass _ENTERPRISE_BannedKeywords(CustomLogger):\n    # Class variables or attributes\n    def __init__(self):\n        banned_keywords_list = litellm.banned_keywords_list\n\n        if banned_keywords_list is None:\n            raise Exception(\n                \"`banned_keywords_list` can either be a list or filepath. None set.\"\n            )\n\n        if isinstance(banned_keywords_list, list):\n            self.banned_keywords_list = banned_keywords_list\n\n        if isinstance(banned_keywords_list, str):  # assume it's a filepath\n            try:\n                with open(banned_keywords_list, \"r\") as file:\n                    data = file.read()\n                    self.banned_keywords_list = data.split(\"\\n\")\n            except FileNotFoundError:\n                raise Exception(\n                    f\"File not found. banned_keywords_list={banned_keywords_list}\"\n                )\n            except Exception as e:\n                raise Exception(\n                    f\"An error occurred: {str(e)}, banned_keywords_list={banned_keywords_list}\"","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/enterprise/enterprise_hooks/banned_keywords.py#L11-L47","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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).","Set drop_params=True to drop legacy params automatically.","Remove response_format handling - gpt-image-1 returns base64 by default.","Build per-model param dicts instead of one shared dict."],"exampleFix":"# before\nlitellm.image_generation(model=\"gpt-image-1\", prompt=\"cat\", style=\"natural\", response_format=\"b64_json\")\n\n# after\nlitellm.image_generation(model=\"gpt-image-1\", prompt=\"cat\", background=\"transparent\")\n# or: litellm.drop_params = True","handlingStrategy":"validation","validationCode":"GPT_IMAGE_SUPPORTED = {\"prompt\", \"n\", \"size\", \"quality\", \"background\", \"output_format\", \"output_compression\", \"moderation\", \"user\", \"partial_images\"}\n\ndef validate_gpt_image_params(params: dict) -> list[str]:\n    return [k for k in params if k not in GPT_IMAGE_SUPPORTED and k != \"prompt\"]  # non-empty => will raise","typeGuard":"def param_set_is_supported(params: dict, supported: set[str]) -> bool:\n    return set(params).issubset(supported)","tryCatchPattern":"try:\n    img = litellm.image_generation(model=\"gpt-image-1\", prompt=p, **params)\nexcept ValueError as e:\n    if \"not supported\" in str(e):\n        params = {k: v for k, v in params.items() if k in GPT_IMAGE_SUPPORTED}\n        img = litellm.image_generation(model=\"gpt-image-1\", prompt=p, **params)\n    else:\n        raise","preventionTips":["Strip style/response_format when switching dalle models to gpt-image-1.","gpt-image-1 returns b64 by default - remove response_format handling entirely."],"tags":["openai","gpt-image-1","image-generation","parameter-validation","litellm"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}