The following examples present different image generation use cases. Each example provides an explanation of the fields that are used for the image generation.
{
"taskType": "TEXT_IMAGE",
"textToImageParams": {
"text": string
,
"negativeText": string
},
"imageGenerationConfig": {
"width": int
,
"height": int
,
"quality": "standard" | "premium",
"cfgScale": float
,
"seed": int
,
"numberOfImages": int
}
}
The following textToImageParams
fields are used in this request:
-
text
(Required) – A text prompt to generate the image. The prompt must be 1-1024 characters in length. -
negativeText
(Optional) – A text prompt to define what not to include in the image. This value must be 1-1024 characters in length.
Note
Avoid using negating words (“no”, “not”, “without”, etc.) in your text
and
negativeText
values. For example, if you do not want mirrors in an image,
instead of including "no mirrors" or "without mirrors" in the text
field, use the
word "mirrors" in the negativeText
field.
The imageGenerationConfig
field is common to all task types except
BACKGROUND_REMOVAL
. It is optional and contains the following fields. If you omit
this object, the default configurations are used.
-
width
andheight
(Optional) – Define the size and aspect ratio of the generated image. Both default to 1024. For the full list of supported resolutions, see Supported image resolutions. -
quality
(Optional) - Specifies the quality to use when generating the image - "standard" (default) or "premium". -
cfgScale
(Optional) – Specifies how strongly the generated image should adhere to the prompt. Use a lower value to introduce more randomness in the generation.Minimum Maximum Default 1.1 10 6.5 -
numberOfImages
(Optional) – The number of images to generate.Minimum Maximum Default 1 5 1 -
seed
(Optional) – Determines the initial noise setting for the generation process. Changing the seed value while leaving all other parameters the same will produce a totally new image that still adheres to your prompt, dimensions, and other settings. It is common to experiment with a variety of seed values to find the perfect image.Minimum Maximum Default 0 858,993,459 12
Important
Resolution (width
and height
), numberOfImages
, and
quality
all have an impact on the time it takes for generation to complete. The
AWS SDK has a default read_timeout
of 60 seconds which can easily be exceeded
when using higher values for these parameters. Therefore, it is recommended that you increase
the read_timeout
of your invocation calls to at least 5 minutes (300 seconds).
The code examples demonstrate how to do this.