{"record":{"id":"f79a4f0dcc424f22","repo":"BerriAI/litellm","slug":"violated-guardrail-policy","errorCode":null,"errorMessage":"Violated guardrail policy","messagePattern":"Violated guardrail policy","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"warning","filePath":"enterprise/enterprise_hooks/aporia_ai.py","lineNumber":130,"sourceCode":"        \"\"\"\n\n        response = await self.async_handler.post(\n            url=self.aporia_api_base + \"/validate\",\n            data=_json_data,\n            headers={\n                \"X-APORIA-API-KEY\": self.aporia_api_key,\n                \"Content-Type\": \"application/json\",\n            },\n        )\n        verbose_proxy_logger.debug(\"Aporia AI response: %s\", response.text)\n        if response.status_code == 200:\n            # check if the response was flagged\n            _json_response = response.json()\n            action: str = _json_response.get(\n                \"action\"\n            )  # possible values are modify, passthrough, block, rephrase\n            if action == \"block\":\n                raise HTTPException(\n                    status_code=400,\n                    detail={\n                        \"error\": \"Violated guardrail policy\",\n                        \"aporia_ai_response\": _json_response,\n                    },\n                )\n\n    async def async_post_call_success_hook(\n        self,\n        data: dict,\n        user_api_key_dict: UserAPIKeyAuth,\n        response,\n    ):\n        from litellm.proxy.common_utils.callback_utils import (\n            add_guardrail_to_applied_guardrails_header,\n        )\n\n        \"\"\"","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/enterprise/enterprise_hooks/aporia_ai.py#L112-L148","documentation":"Parameter validation for DALL-E 3 image generation: same mechanism as other image models - each non-default param must be in get_supported_openai_params(model) or the call raises ValueError (listing supported params) unless drop_params=True. DALL-E 3 supports quality and style but rejects DALL-E 2-era or GPT-image-era params (e.g. response_format restrictions, background, moderation) that are not in its supported set.","triggerScenarios":"Calling litellm.image_generation(model='dall-e-3', ...) with unsupported params such as response_format='b64_json' on endpoints that disallow it, background, output_format, or any param outside dall-e-3's supported list, without drop_params=True.","commonSituations":"Generic image wrappers forwarding every kwarg; migrating dall-e-2 code that relied on response_format; new gpt-image-1 params copy-pasted into dall-e-3 calls; router-level default params applied model-agnostically.","solutions":["Trim the call to only the params listed in the error message (dall-e-3: prompt, n, quality, size, style, user).","Set drop_params=True to auto-drop unsupported keys.","Switch to gpt-image-1 if you need the newer parameter set (background, output_format, moderation).","Check get_supported_openai_params('dall-e-3') at startup and validate your param dict against it."],"exampleFix":"# before\nlitellm.image_generation(model=\"dall-e-3\", prompt=\"cat\", output_format=\"png\", background=\"transparent\")\n\n# after\nlitellm.image_generation(model=\"dall-e-3\", prompt=\"cat\", quality=\"hd\", style=\"natural\")\n# or: litellm.drop_params = True","handlingStrategy":"validation","validationCode":"DALLE3_SUPPORTED = {\"prompt\", \"n\", \"quality\", \"size\", \"style\", \"user\"}\n\ndef validate_dalle3_params(params: dict) -> list[str]:\n    return [k for k in params if k not in DALLE3_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=\"dall-e-3\", 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 DALLE3_SUPPORTED}\n        img = litellm.image_generation(model=\"dall-e-3\", prompt=p, **params)\n    else:\n        raise","preventionTips":["Do not forward dall-e-2 response_format or gpt-image params to dall-e-3.","Validate params per model at the edge of your wrapper before litellm sees them."],"tags":["openai","dall-e-3","image-generation","parameter-validation","litellm"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}