Error 400 when generating an image with DALL-e with a specific prompt

I’m running into an issue when generating an image with DALL-e 3 API with a specific prompt:

from openai import AsyncOpenAI

API_KEY = os.environ.get(“OPENAI_KEY”)

client = AsyncOpenAI(api_key=API_KEY)

prompt = ‘Cowboy shot. Sketchy graphic style, quick, rough and imprecise marker strokes, not too detailed, with few strokes, white background, black color for lines and a light gray scale for shades. Oliver is a tall, lean man with short brown hair, wearing a navy-blue jumpsuit and carrying an electrician’s tool belt. Oliver in his van, observing the property that needs a more sustainable heating solution.’

response = await client.images.generate(model=“dall-e-3”, size=“1792x1024”, prompt=prompt)

The previous code generates the following error (without message):
BadRequestError: Error code: 400 - {'error': {'message': None, 'type': 'image_generation_user_error', 'param': None, 'code': None}}

It works with other prompts.

What’s happening?

1 Like

The AI moderator probably doesn’t want to see any cowboys getting shot.

“Composition: Framed from mid-thigh to head. Sketchy graphic style, quick, rough and imprecise marker strokes, not too detailed, with few strokes, white background, black color for lines and a light gray scale for shades…”

2 Likes

Interesting… But in that case it’s obviously a misunderstanding: wikipedia says that “An American shot or cowboy shot is a medium-long (“knee”) film shot of a group of characters…”. This should be reported as a bug I guess.

The images endpoint moderation has too many layers of such “bugs”. It is simply not smart. A single word in any context can block the output.

Find the extra word:

Well, given the expertise OpenAI gained on language understanding, I regret that they use simple keywords to filter out problematic prompts… But thanks for the input, that was very helpful to solve the issue!

2 Likes