Create an image
Creates an image given a prompt.
Request
POST
https://ai.api.cloud.yandex.net/v1/images/generations
Body
application/json
{
"prompt": "A cute baby sea otter",
"model": "art://<folder_id>/aliceai-image-art-3.0",
"n": 1,
"quality": "example",
"response_format": "example",
"output_format": "example",
"output_compression": 100,
"stream": true,
"partial_images": null,
"size": "1x1",
"moderation": "auto",
"background": "transparent",
"style": "example",
"user": "example"
}
|
Name |
Description |
|
prompt |
Type: string A text description of the desired image. The maximum length is 32k characters and depends on the model. Example: |
|
background |
Type: string | null CURRENTLY NOT SUPPORTED Default: Enum: |
|
model |
Type: string | null The model to use for image generation. Example: |
|
moderation |
Type: string | null CURRENTLY NOT SUPPORTED Default: Enum: |
|
n |
Type: integer | null CURRENTLY NOT SUPPORTED Default: Min value: Max value: |
|
output_compression |
Type: integer | null CURRENTLY NOT SUPPORTED The compression level (0-100%) for the generated images. This parameter is only supported for the image models with the Default: |
|
output_format |
Type: string | null CURRENTLY NOT SUPPORTED Example: |
|
partial_images |
Type: unknown CURRENTLY NOT SUPPORTED Example: |
|
quality |
Type: string | null CURRENTLY NOT SUPPORTED Example: |
|
response_format |
Type: string | null CURRENTLY NOT SUPPORTED Example: |
|
size |
Type: string | null The aspect ratio of generated image. Must be two positive integer values separated by an Default: Example: |
|
stream |
Type: boolean | null CURRENTLY NOT SUPPORTED |
|
style |
Type: string | null CURRENTLY NOT SUPPORTED Example: |
|
user |
Type: string CURRENTLY NOT SUPPORTED Example: |
Responses
200 OK
OK
Body
application/json
{
"created": 0,
"data": [
{
"b64_json": "example",
"url": "example",
"revised_prompt": "example"
}
],
"background": "transparent",
"output_format": "png",
"size": "1024x1024",
"quality": "low",
"usage": {
"input_tokens": 0,
"total_tokens": 0,
"output_tokens": 0,
"output_tokens_details": {
"image_tokens": 0,
"text_tokens": 0
},
"input_tokens_details": {
"text_tokens": 0,
"image_tokens": 0
}
}
}
|
Name |
Description |
|
created |
Type: integer The Unix timestamp (in seconds) of when the image was created. |
|
background |
Type: string The background parameter used for the image generation. Either Enum: |
|
data |
Type: Image[] The list of generated images. Example
|
|
output_format |
Type: string The output format of the image generation. Either Enum: |
|
quality |
Type: string The quality of the image generated. Either Enum: |
|
size |
Type: string The size of the image generated. Either Enum: |
|
usage |
Type: ImageGenUsage The token usage information for the image generation. Example
|
Image
Represents the content or the URL of a generated image.
|
Name |
Description |
|
b64_json |
Type: string The base64-encoded JSON of the generated image. Example: |
|
revised_prompt |
Type: string CURRENTLY NOT SUPPORTED The revised prompt that was used to generate the image. Example: |
|
url |
Type: string CURRENTLY NOT SUPPORTED The URL of the generated image generated image. Example: |
Example
{
"b64_json": "example",
"url": "example",
"revised_prompt": "example"
}
ImageGenOutputTokensDetails
The output token details for the image generation.
|
Name |
Description |
|
image_tokens |
Type: integer The number of image output tokens generated by the model. |
|
text_tokens |
Type: integer The number of text output tokens generated by the model. |
Example
{
"image_tokens": 0,
"text_tokens": 0
}
ImageGenInputUsageDetails
The input tokens detailed information for the image generation.
|
Name |
Description |
|
image_tokens |
Type: integer The number of image tokens in the input prompt. |
|
text_tokens |
Type: integer The number of text tokens in the input prompt. |
Example
{
"text_tokens": 0,
"image_tokens": 0
}
ImageGenUsage
The token usage information for the image generation.
|
Name |
Description |
|
input_tokens |
Type: integer The number of tokens (images and text) in the input prompt. |
|
input_tokens_details |
Type: ImageGenInputUsageDetails The input tokens detailed information for the image generation. Example
|
|
output_tokens |
Type: integer The number of output tokens generated by the model. |
|
total_tokens |
Type: integer The total number of tokens (images and text) used for the image generation. |
|
output_tokens_details |
Type: ImageGenOutputTokensDetails The output token details for the image generation. Example
|
Example
{
"input_tokens": 0,
"total_tokens": 0,
"output_tokens": 0,
"output_tokens_details": {
"image_tokens": 0,
"text_tokens": 0
},
"input_tokens_details": {
"text_tokens": 0,
"image_tokens": 0
}
}
Body
text/event-stream
{
"type": "image_generation.partial_image",
"b64_json": "example",
"created_at": 0,
"size": "1024x1024",
"quality": "low",
"background": "transparent",
"output_format": "png",
"partial_image_index": 0
}
Any of 2 types
-
Type: ImageGenPartialImageEvent
Emitted when a partial image is available during image generation streaming.
Example
{ "type": "image_generation.partial_image", "b64_json": "example", "created_at": 0, "size": "1024x1024", "quality": "low", "background": "transparent", "output_format": "png", "partial_image_index": 0 } -
Type: ImageGenCompletedEvent
Emitted when image generation has completed and the final image is available.
Example
{ "type": "image_generation.completed", "b64_json": "example", "created_at": 0, "size": "1024x1024", "quality": "low", "background": "transparent", "output_format": "png", "usage": { "total_tokens": 0, "input_tokens": 0, "output_tokens": 0, "input_tokens_details": { "text_tokens": 0, "image_tokens": 0 } } }
ImageGenPartialImageEvent
Emitted when a partial image is available during image generation streaming.
|
Name |
Description |
|
b64_json |
Type: string Base64-encoded partial image data, suitable for rendering as an image. Example: |
|
background |
Type: string The background setting for the requested image. Enum: |
|
created_at |
Type: integer The Unix timestamp when the event was created. |
|
output_format |
Type: string The output format for the requested image. Enum: |
|
partial_image_index |
Type: integer 0-based index for the partial image (streaming). |
|
quality |
Type: string The quality setting for the requested image. Enum: |
|
size |
Type: string The size of the requested image. Enum: |
|
type |
Type: string The type of the event. Always Const: Example: |
Example
{
"type": "image_generation.partial_image",
"b64_json": "example",
"created_at": 0,
"size": "1024x1024",
"quality": "low",
"background": "transparent",
"output_format": "png",
"partial_image_index": 0
}
ImagesUsage
CURRENTLY NOT SUPPORTED
The token usage information for the image generation.
|
Name |
Description |
||||
|
input_tokens |
Type: integer The number of tokens (images and text) in the input prompt. |
||||
|
input_tokens_details |
Type: object
The input tokens detailed information for the image generation. Example
|
||||
|
output_tokens |
Type: integer The number of image tokens in the output image. |
||||
|
total_tokens |
Type: integer The total number of tokens (images and text) used for the image generation. |
Example
{
"total_tokens": 0,
"input_tokens": 0,
"output_tokens": 0,
"input_tokens_details": {
"text_tokens": 0,
"image_tokens": 0
}
}
ImageGenCompletedEvent
Emitted when image generation has completed and the final image is available.
|
Name |
Description |
|
b64_json |
Type: string Base64-encoded image data, suitable for rendering as an image. Example: |
|
background |
Type: string The background setting for the generated image. Enum: |
|
created_at |
Type: integer The Unix timestamp when the event was created. |
|
output_format |
Type: string The output format for the generated image. Enum: |
|
quality |
Type: string The quality setting for the generated image. Enum: |
|
size |
Type: string The size of the generated image. Enum: |
|
type |
Type: string The type of the event. Always Const: Example: |
|
usage |
Type: ImagesUsage CURRENTLY NOT SUPPORTED The token usage information for the image generation. Example
|
Example
{
"type": "image_generation.completed",
"b64_json": "example",
"created_at": 0,
"size": "1024x1024",
"quality": "low",
"background": "transparent",
"output_format": "png",
"usage": {
"total_tokens": 0,
"input_tokens": 0,
"output_tokens": 0,
"input_tokens_details": {
"text_tokens": 0,
"image_tokens": 0
}
}
}