> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apiyi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Nano Banana / GPT-Image: How to Get Stable Output from Vague Consumer Prompts?

> A practical FAQ for consumer-facing products calling APIYI image models: lock the image-output intent, rewrite vague prompts into six visual elements, separate redraws from edits, and measure what actually succeeds.

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:

| Type | Typical symptom | Does the preset help? | What to do |
| - | - | - | - |
| Intent mismatch | "Sure, I can help design that...", asking which style the user wants, or returning prompt advice only | Yes | Parameter-level lock + system prompt + intent routing |
| Safety refusal | "I can't help with that request" | No | Neutralize sensitive wording, retry with different phrasing, or switch models |
| Text inside the image | An image is returned, but the cup or sign contains a fake brand or gibberish | Partially | Ban text by default; specify exact content and position when text is wanted |

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](https://docs.apiyi.com/en/api-capabilities/nano-banana-pro-guarantee.md) and the [Gemini image API error guide](https://docs.apiyi.com/en/api-capabilities/gemini-image-error-handling.md) 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:

| Integration path | Hard constraint | Notes |
| - | - | - |
| Gemini native `generateContent` | `generationConfig.responseModalities: ["IMAGE"]` | Hardening only; still scan `parts` for the image instead of hard-coding an index |
| OpenAI-compatible `chat/completions` | System message + response scanning | Usually no `responseModalities`; relies on the prompt and response parsing |
| Image-only endpoint `/v1/images/generations` | No system role, and it does not return chat text | Put the constraint in the prompt; failures are usually safety, 400, or timeout |
| Tool-calling path | `tool_choice` to force the image tool | Stronger than any prompt |

A preset you can use directly:

```text theme={null}
You are an image generator, not a chat assistant.

For every user message:
1. Generate an image directly. Do not reply with text, explanations, questions, confirmations, or advice.
2. If the description is incomplete, fill in the most common and reasonable interpretation and generate immediately. Do not ask the user to clarify.
3. Unless the user explicitly asks for visible text, do not include any text, letters, numbers, watermarks, or logos in the image.
4. When the user asks to modify the previous image, edit that image instead of generating a new one.
```

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."

> [!WARNING]
>
> 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.

| Element | What goes wrong when missing | Example |
| - | - | - |
| Subject | The model invents props or changes the subject | "A round-faced orange cat, sitting, facing the camera" |
| Environment | Random background; a series looks inconsistent | "Light wood floor, blurred living room behind" |
| Lighting | Flat, artificial-looking light | "Soft window light from the left" |
| Lens and angle | Uncontrolled perspective and depth of field | "85mm, shallow depth of field, eye level" |
| Color and medium | Default oversaturated "render" look | "Warm tones, low saturation, natural texture" |
| Composition | Subject always centered | "Subject centered, generous negative space" |

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:

```text theme={null}
- Add only visual decisions; do not introduce subjects, props, or brands the user did not ask for
- Preserve everything the user explicitly specified
- Do not use empty quality words such as "8K", "ultra HD", "masterpiece", or "perfect"
- Output only the prompt body; no explanation and no bullet points
- No text in the image by default; when the user asks for text, preserve the exact wording, language, and position
```

For the full rewrite-layer implementation, see [Advanced image workflows](https://docs.apiyi.com/en/api-capabilities/image-advanced-workflow.md).

## Layer 3: Defaults and intent routing

Users will not fill in parameters, so the product must supply defaults:

| User wording | Inferred aspect ratio |
| - | - |
| Avatar, logo, sticker | 1:1 |
| Phone wallpaper, vertical | 9:16 |
| Poster, cover | 3:4 or 2:3 |
| Desktop wallpaper, horizontal banner | 16:9 |
| Not specified | Use one fixed default for your main use case; do not randomize |

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:

| User input | Intent | Action |
| - | - | - |
| "Draw a cat", "Make me an avatar" | New generation | Rewrite + generate |
| "Change the background to a beach", "Make it cuter" | Edit | Pass the previous image and edit it; do not regenerate |
| "Hello", "How much is this", "Why is it so expensive" | Not image generation | Reply in text or guide the user; do not draw |

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](https://docs.apiyi.com/en/api-capabilities/image-api-best-practices.md) 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](https://docs.apiyi.com/en/api-capabilities/image-advanced-workflow.md).

## Layer 5: How to recover from failures

| Failure | Automatic action | Limit |
| - | - | - |
| Text-only reply (intent mismatch) | Retry once with a stronger instruction: "You must output an image, not text" | 1 retry |
| Safety refusal | Neutralize sensitive wording and retry once with different phrasing; if it still fails, switch models or give the user an actionable message | 1 retry |
| HTTP 200 but no image | Retry once; if it still fails, switch models | 1 retry |
| Timeout or disconnect | Set timeouts by model tier; before retrying, check whether the previous request was already billed | 1 retry |

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](https://docs.apiyi.com/en/api-capabilities/image-api-best-practices.md). For refusal detection, see the [Gemini image API error guide](https://docs.apiyi.com/en/api-capabilities/gemini-image-error-handling.md).

## 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](https://docs.apiyi.com/en/api-capabilities/image-generation-success-tips.md).

## How to measure image-generation success rate

Do not count HTTP 200 as success. Instrument three layers:

| Layer | Metric | Meaning |
| - | - | - |
| API layer | `has_image`, HTTP status, refusal text | A 200 response with text only is still a failure |
| Result layer | Whether the user redraws or edits immediately | An immediate redraw means the result was unusable |
| Business layer | Download, share, save, payment | Closest to real success |

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.

## Related docs

> [card] [Advanced image workflows](https://docs.apiyi.com/en/api-capabilities/image-advanced-workflow.md)
>
> The eight layers consumer products build around the model, including rewrite-layer code and sampling.

> [card] [How to generate satisfactory images](https://docs.apiyi.com/en/api-capabilities/image-generation-success-tips.md)
>
> What to do when a single result is disappointing: rewrite, retry, switch models, and test.

> [card] [Image prompt doctor skill](https://docs.apiyi.com/en/api-capabilities/image-prompt-doctor.md)
>
> An installable skill for pre-generation checks and post-generation diagnosis.

> [card] [Gemini image API error guide](https://docs.apiyi.com/en/api-capabilities/gemini-image-error-handling.md)
>
> Detect 200-with-no-image and safety refusals, and write consumer-facing messages.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.