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: A cute baby sea otter

background

Type: string | null

CURRENTLY NOT SUPPORTED
Allows to set transparency for the background of the generated image(s). If transparent, the output format needs to support transparency, so it should be set to either png (default value) or webp.

Default: auto

Enum: transparent, opaque, auto

model

Type: string | null

The model to use for image generation.

Example: art://<folder_id>/aliceai-image-art-3.0

moderation

Type: string | null

CURRENTLY NOT SUPPORTED
Control the content-moderation level for images generated by the image models.

Default: auto

Enum: low, auto

n

Type: integer | null

CURRENTLY NOT SUPPORTED
The number of images to generate.

Default: 1

Min value: 1

Max value: 10

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 webp or jpeg output formats, and defaults to 100.

Default: 100

output_format

Type: string | null

CURRENTLY NOT SUPPORTED
The format in which the generated images are returned.

Example: example

partial_images

Type: unknown

CURRENTLY NOT SUPPORTED
Generate partial images. Defaults to false.

Example: null

quality

Type: string | null

CURRENTLY NOT SUPPORTED
The quality of the image that will be generated.

Example: example

response_format

Type: string | null

CURRENTLY NOT SUPPORTED
The format in which generated images are returned. URLs are only valid for 60 minutes after the image has been generated.

Example: example

size

Type: string | null

The aspect ratio of generated image. Must be two positive integer values separated by an x: 1536x1024 (landscape), 1024x1536 (portrait), 1x1, 1024x1024, or auto (square, default value).

Default: auto

Example: 1x1

stream

Type: boolean | null

CURRENTLY NOT SUPPORTED
Generate the image in streaming mode. Defaults to false.

style

Type: string | null

CURRENTLY NOT SUPPORTED
The style of the generated images. Vivid causes the model to lean towards generating hyper-real and dramatic images. Natural causes the model to produce more natural, less hyper-real looking images.

Example: example

user

Type: string

CURRENTLY NOT SUPPORTED
A unique identifier representing your end-user, which can help AI Studio to monitor and detect abuse.

Example: 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 transparent or opaque.

Enum: transparent, opaque

data

Type: Image[]

The list of generated images.

Example
[
          {
            "b64_json": "example",
            "url": "example",
            "revised_prompt": "example"
          }
        ]
        

output_format

Type: string

The output format of the image generation. Either png, webp, or jpeg.

Enum: png, webp, jpeg

quality

Type: string

The quality of the image generated. Either low, medium, or high.

Enum: low, medium, high

size

Type: string

The size of the image generated. Either 1024x1024, 1024x1536, or 1536x1024.

Enum: 1024x1024, 1024x1536, 1536x1024

usage

Type: ImageGenUsage

The token usage information for the image generation.

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
          }
        }
        

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

revised_prompt

Type: string

CURRENTLY NOT SUPPORTED

The revised prompt that was used to generate the image.

Example: example

url

Type: string

CURRENTLY NOT SUPPORTED

The URL of the generated image generated image.

Example: 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
{
          "text_tokens": 0,
          "image_tokens": 0
        }
        

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
{
          "image_tokens": 0,
          "text_tokens": 0
        }
        
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: example

background

Type: string

The background setting for the requested image.

Enum: transparent, opaque, auto

created_at

Type: integer

The Unix timestamp when the event was created.

output_format

Type: string

The output format for the requested image.

Enum: png, webp, jpeg

partial_image_index

Type: integer

0-based index for the partial image (streaming).

quality

Type: string

The quality setting for the requested image.

Enum: low, medium, high, auto

size

Type: string

The size of the requested image.

Enum: 1024x1024, 1024x1536, 1536x1024, auto

type

Type: string

The type of the event. Always image_generation.partial_image.

Const: image_generation.partial_image

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

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.

The input tokens detailed information for the image generation.

Example
{
          "text_tokens": 0,
          "image_tokens": 0
        }
        

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

background

Type: string

The background setting for the generated image.

Enum: transparent, opaque, auto

created_at

Type: integer

The Unix timestamp when the event was created.

output_format

Type: string

The output format for the generated image.

Enum: png, webp, jpeg

quality

Type: string

The quality setting for the generated image.

Enum: low, medium, high, auto

size

Type: string

The size of the generated image.

Enum: 1024x1024, 1024x1536, 1536x1024, auto

type

Type: string

The type of the event. Always image_generation.completed.

Const: image_generation.completed

Example: example

usage

Type: ImagesUsage

CURRENTLY NOT SUPPORTED

The token usage information for the image generation.

Example
{
          "total_tokens": 0,
          "input_tokens": 0,
          "output_tokens": 0,
          "input_tokens_details": {
            "text_tokens": 0,
            "image_tokens": 0
          }
        }
        
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
            }
          }
        }
        
Предыдущая
Следующая