BerriAI/litellm · warning · HTTPException
Violated guardrail policy
Error message
Violated guardrail policy
What it means
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.
Source
Thrown at enterprise/enterprise_hooks/aporia_ai.py:130
"""
response = await self.async_handler.post(
url=self.aporia_api_base + "/validate",
data=_json_data,
headers={
"X-APORIA-API-KEY": self.aporia_api_key,
"Content-Type": "application/json",
},
)
verbose_proxy_logger.debug("Aporia AI response: %s", response.text)
if response.status_code == 200:
# check if the response was flagged
_json_response = response.json()
action: str = _json_response.get(
"action"
) # possible values are modify, passthrough, block, rephrase
if action == "block":
raise HTTPException(
status_code=400,
detail={
"error": "Violated guardrail policy",
"aporia_ai_response": _json_response,
},
)
async def async_post_call_success_hook(
self,
data: dict,
user_api_key_dict: UserAPIKeyAuth,
response,
):
from litellm.proxy.common_utils.callback_utils import (
add_guardrail_to_applied_guardrails_header,
)
"""View on GitHub (pinned to 6c2dcb801b)
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.
Example fix
# before litellm.image_generation(model="dall-e-3", prompt="cat", output_format="png", background="transparent") # after litellm.image_generation(model="dall-e-3", prompt="cat", quality="hd", style="natural") # or: litellm.drop_params = True
Defensive patterns
Strategy: validation
Validate before calling
DALLE3_SUPPORTED = {"prompt", "n", "quality", "size", "style", "user"}
def validate_dalle3_params(params: dict) -> list[str]:
return [k for k in params if k not in DALLE3_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="dall-e-3", 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 DALLE3_SUPPORTED}
img = litellm.image_generation(model="dall-e-3", prompt=p, **params)
else:
raise Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Unknown hook: {hook_name}. Available hooks: {list(ENTERPRISE
- `banned_keywords_list` can either be a list or filepath. Non
- Unclassified keys in {PRICES_PATH.name}: {', '.join(unclassi
- No Braintrust API token provided. Pass via Authorization hea
- Braintrust API error: {e.response.text}
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/f79a4f0dcc424f22.
Report an issue: GitHub.