Console

Image Generation

POST/v1/images/generations

Text-to-image endpoint that generates one image from a text description.

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.

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; the image still keeps its AIGC metadata.

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: 2 error codes

Authentication failed, or the platform safety review blocked the request.

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: upstream_invalid_result

The upstream result failed structure, model version, or usage validation. Keep the task and trace identifiers and contact the service provider.