Skip to main content
This FAQ is for consumer-facing product teams calling image models through APIYI. It covers gemini-3-pro-image (Nano Banana Pro), gemini-3.1-flash-image (Nano Banana 2), the gpt-image-2 / gpt-image-2.5 series, and comparable models such as Seedream and FLUX. Differences between integration paths are called out where they matter.

Short answer

Keep the preset instruction “generate an image directly; do not chat or give advice,” but understand what it fixes: intent mismatch, where the model treats a drawing request as a conversation. Stable output from vague consumer prompts needs five layers:
  1. Intent locking: enforce image output at the parameter level where possible, with a system prompt as fallback.
  2. Rewrite layer: expand the casual request into six visual elements: subject, environment, lighting, lens, color, and composition.
  3. Defaults and intent routing: aspect ratio, style presets, and routing between generation, edits, and questions.
  4. Multi-turn editing: pass the previous image for follow-ups instead of regenerating.
  5. Failure recovery: handle intent mismatch, safety refusal, and empty responses separately.
A preset instruction reduces text-only replies. It does not fix wrong subjects, empty scenes, or poor composition, which are the main reasons consumer users are unhappy.

Why a single “generate the image” instruction is not enough

When no image comes back, there are at least three different causes, and they need different fixes: Safety refusals have a clear signature: output tokens are only around 100 to 200, or candidatesTokenCount is 0. Repeating “you must generate an image” will not change the policy decision; it only burns quota. See Nano Banana Pro failure compensation and the Gemini image API error guide for details.

Layer 1: Make image output a hard constraint

A system prompt is a soft constraint. Parameters take precedence. Enforce the output type first where the API allows it: A preset you can use directly:
Where to put it depends on the path:
  • Gemini native: prefer systemInstruction. If it does not take effect for the current model or route, put the same text in the first text part of contents.
  • OpenAI-compatible: use a system message.
  • Image-only endpoint: there is no system role, so compress the first three rules into a prefix, for example: “Generate an image directly. If the description is incomplete, use the most reasonable interpretation. Unless explicitly requested, do not include any text, watermarks, or logos.”
Do not apply this preset to every conversation. Otherwise a user asking “hello” or “how much does this cost” will also get an image. Add a dedicated image-generation mode, or run intent routing before applying the preset.

Layer 2: Rewrite casual input into six visual elements

Casual input is not merely short; it is missing decisions. The rewrite layer should fill in those decisions, not inflate the prompt. The most important rule: do not send the user’s raw wording straight to the image model. Run it through the rewrite layer first. A real before-and-after example:
  • User input: “Draw a cute cat”
  • Rewritten: “A round-faced orange cat sitting on a light wood floor, facing the camera, soft window light from the left, shallow depth of field, blurred living room in the background, warm tones, square composition, no text anywhere in the image.”
The rewrite rules can go directly into the text model’s system prompt:
For the full rewrite-layer implementation, see Advanced image workflows.

Layer 3: Defaults and intent routing

Users will not fill in parameters, so the product must supply defaults: Style is also better fixed with presets: realistic, illustration, anime, 3D, watercolor, and so on. Each preset is a fixed prompt fragment plus a reference image set. Letting users tap a preset is far more stable than asking them to describe a style. Intent routing needs at least three branches: Models can also be routed by task: use the gpt-image-2.5 series for posters and logos with visible text; use gemini-3-pro-image for photoreal portraits and product shots; start with gemini-3.1-flash-image for speed and cost, then upgrade on failure. See Image API best practices for selection guidance.

Layer 4: Treat follow-ups as edits, not new generations

The most common drop-off point in consumer products: the user says “make it cuter,” and the product generates a completely different image. Pass the previous image into an image-edit call instead of treating the follow-up as a fresh prompt. Separate three kinds of follow-ups:
  • “Another one”, “Change the style”: resample with the same prompt, or switch presets. This is not an edit.
  • “Change the background to a beach”, “Remove the hat”: edit the previous image.
  • “Why does it look bad”, “Can it be cheaper”: reply in text; do not generate an image.
The native Gemini endpoint for the Nano Banana series supports cumulative editing by passing the previous image back as a role: "model" turn. Reverse-engineered routes do not. See the refinement section of Advanced image workflows.

Layer 5: How to recover from failures

Do not retry indefinitely. Repeating a request that was refused for safety burns quota and may trigger risk controls. The consumer-facing message should tell the user which phrase might have triggered the refusal, not just “generation failed.” For timeout settings, see Image API best practices. For refusal detection, see the Gemini image API error guide.

Text inside the image: ban by default, specify when needed

Models that are good at rendering text, such as the gpt-image-2.5 series and Nano Banana Pro, may add text even when the user did not ask for it, producing fake brands or gibberish. Add this to the end of the prompt by default:
Do not include any text, letters, numbers, watermarks, or logos in the image.
When the user explicitly wants text, do not just say “add a title.” Specify:
  • The exact wording, character by character, with no homophones
  • The language: Chinese or English
  • The position: top center, bottom right, and so on
  • The font style and color
For text-heavy tasks, use quality: "xhigh" or "max" with gpt-image-2.5; Nano Banana 2 / 2 Lite can enable thinkingLevel: "high", while gemini-3-pro-image does not support that parameter. Quality tiers directly affect output tokens and cost, so do not max them out globally. See How to generate satisfactory images.

How to measure image-generation success rate

Do not count HTTP 200 as success. Instrument three layers: For every request, log at least: the original prompt, rewritten prompt, model, size / quality / aspectRatio, latency, whether an image was returned, refusal reason, retry count, and the user’s next action. Review the failure distribution weekly; it beats tuning prompts by feel.

Minimum implementation checklist

  1. Add a dedicated image-generation mode; do not apply the “must draw” preset to non-image requests.
  2. Enforce output at the parameter level where possible: responseModalities: ["IMAGE"] for Gemini native, tool_choice for tool-calling paths.
  3. Add the rewrite layer: a cheap text model + six elements + no text by default.
  4. Fix defaults: aspect ratio, style presets, quality tier.
  5. Pass the previous image for follow-up edits, and separate redraws, edits, and questions.
  6. Retry at most once; do not fight safety refusals.
  7. Define success in your analytics and review it weekly.

Advanced image workflows

The eight layers consumer products build around the model, including rewrite-layer code and sampling.

How to generate satisfactory images

What to do when a single result is disappointing: rewrite, retry, switch models, and test.

Image prompt doctor skill

An installable skill for pre-generation checks and post-generation diagnosis.

Gemini image API error guide

Detect 200-with-no-image and safety refusals, and write consumer-facing messages.