Console

Text-to-Image

POST/v1/images/generations

Text-to-image endpoint; generate directly, or enhance the prompt and generate the image within the same request.

Request parameters

FieldTypeRequiredDescription
model: stringRequired

Model ID. Use the stable model ID for regular calls, or a snapshot model ID when you need to reproduce results from a fixed version.

prompt: stringRequired

The text description of the image to generate; a non-empty string of at most 4,000 characters.

prompt_enhance: booleanOptional

Whether to enhance the prompt before generating the image within the same Image task; defaults to false.

negative_prompt: stringOptional

Content that should not appear in the image; at most 4,000 characters. The examples use the negative tags recommended in the model card.

size: stringOptional

Image size in the format widthxheight; defaults to 1024x1024. Each side must be 256–2048 and a multiple of 16; the total pixel count must not exceed 2097152.

n: integerOptional

Number of images to generate; only 1 is supported.

seed: integerOptional

Random seed that controls the randomness of generation and makes results reproducible, from 0 to 2^53−1. If omitted, the system generates one at random.

num_inference_steps: integerOptional

Number of inference steps, from 1 to 100.

guidance_scale: numberOptional

Guidance scale, from 0 to 10; an explicit 0 is honored.

response_format: stringOptional

Only url is supported; b64_json is not supported.

output_watermark: objectOptional

Output watermark settings. enabled is a boolean; when omitted, the visible watermark is on by default. Pass {"enabled": false} to turn off the visible watermark.

Return value

On success, the endpoint returns JSON containing the image URL. Currently one PNG is generated per request, and streaming output is not supported.

FieldTypeDescription
created: integer

The creation timestamp in the response.

data: array

The list of generated image results.

data[].url: string

The URL of the generated image.

usage: object

The actual image generation usage.

usage.generated_images: integer

The number of images actually generated.

usage.output_width: integer

The actual image width, in pixels.

usage.output_height: integer

The actual image height, in pixels.

Error codes

HTTPerror.codeTrigger and suggested action
400: invalid_field_value

The body is not valid JSON, a field has an invalid type or value, the request contains unsupported parameters, or the model / version cannot be found. Check field names and parameter ranges; do not pass a separate version for a snapshot model.

403: 3 error codes

Authentication failed, the enhancement model refused the request, or the platform safety review blocked it.

404: resource_not_found

The generated image asset does not exist. Resubmit the generation request; if it recurs, keep the request identifiers and contact the service provider.

429: 2 error codes

The concurrency or request-rate limit was exceeded.

502: 2 error codes

The built-in enhancement result was truncated, or the upstream result failed validation.