Generate Image
xbrush_image_generateGenerate images from text prompts with XBrush AI models. Submit an async request and poll the returned ID to fetch your generated images.
Instructions
Generate images from a text prompt using XBrush AI models. Submits async — poll the returned request_id with xbrush_get_request.
Args: model (string, required): Model ID (e.g. z-image-turbo). Use xbrush_list_models to see options. prompt (string, required): Text description of the image. n (int, optional): Number of images (1-8). Default: 1. negative_prompt (string, optional): Elements to exclude. width (int, optional): Width in pixels (256-4096). Megapixel-based models (flux., z-image-turbo, ...) use it directly (default 1024). Resolution-based models ignore it UNLESS aspect_ratio:"custom" (see aspect_ratio). height (int, optional): Height in pixels (256-4096). Same rules as width. resolution (string, optional): Resolution tier for resolution-based models (gpt-image-2, seedream-, nano-banana-pro/2), e.g. "1K"/"2K"/"4K". aspect_ratio (string, optional): Aspect ratio for resolution-based models. gpt-image-2/-edit: 1:1, 3:2, 2:3, 4:3, 3:4, 4:5, 16:9, 9:16, 21:9, 1.91:1 (1K/2K); only 16:9/9:16/21:9/1.91:1 at 4K. Special value "custom": gpt-image-2/-edit output the exact width×height you pass (both required; each a multiple of 16, longest edge ≤3840, total pixels 655,360–8,294,400) — e.g. width:1024,height:1152,aspect_ratio:"custom" returns 1024×1152. quality (string, optional): low/medium/high — gpt-image-2/-edit only. seed (int, optional): Random seed for reproducibility.
Note: resolution-based models (gpt-image-2, seedream-*, nano-banana-pro/2) ignore width/height — passing them returns an error. Exception: aspect_ratio:"custom" with width+height yields an EXACT pixel size on gpt-image-2/-edit (other resolution models may only keep the ratio or ignore it).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| n | No | Number of images to generate (1-8). Default: 1. | |
| seed | No | Random seed for reproducible results. | |
| model | Yes | Image model to use (e.g. z-image-turbo, flux.2-pro, seedream-5.0-pro, nano-banana-pro). Use xbrush_list_models to see available models. | |
| width | No | Output width in pixels (256-4096) for megapixel-based models (flux.*, z-image-turbo, etc.). Default: 1024. Resolution-based models (gpt-image-2, seedream-*, nano-banana-*) normally ignore it — but with aspect_ratio:"custom", gpt-image-2/-edit output exactly width×height (both required). | |
| height | No | Output height in pixels (256-4096) for megapixel-based models. Default: 1024. Resolution-based models ignore it unless aspect_ratio:"custom" (see width). | |
| prompt | Yes | Text description of the image to generate. | |
| quality | No | Output quality tier. Applies to byResolutionAndQuality models (gpt-image-2/-edit); higher = better and more expensive. Server default is high if omitted. | |
| resolution | No | Output resolution tier for resolution-based models (gpt-image-2, seedream-*, nano-banana-pro/2). Examples: "1K", "2K", "4K". Ignored by megapixel-based models — use width/height for those. | |
| aspect_ratio | No | Aspect ratio for resolution-based models (e.g. "16:9"). gpt-image-2/-edit support 1:1, 3:2, 2:3, 4:3, 3:4, 4:5, 16:9, 9:16, 21:9, 1.91:1 at 1K/2K — at 4K only 16:9, 9:16, 21:9, 1.91:1. Special value "custom" makes gpt-image-2/-edit use width×height as the exact output size (both required, each a multiple of 16, longest edge ≤3840, total pixels 655,360–8,294,400; missing dimensions or out-of-range values return 400). seedream-* / nano-banana-* accept their own sets; an unsupported value is rejected with the list of allowed ratios. | |
| negative_prompt | No | Elements to exclude from the generated image. |