Edit an image

CURRENTLY NOT SUPPORTED

Creates an edited or extended image given one or more source images and a prompt.

Request

POST

https://ai.api.cloud.yandex.net/v1/images/edits
        

Body

multipart/form-data
{
          "image": "example",
          "prompt": "A cute baby sea otter wearing a beret",
          "mask": "example",
          "background": "auto",
          "model": "example",
          "n": 1,
          "size": "1024x1024",
          "response_format": "url",
          "output_format": "png",
          "output_compression": 100,
          "user": "example",
          "input_fidelity": "high",
          "stream": false,
          "partial_images": 1,
          "quality": "auto"
        }
        

Name

Description

image

Any of 2 types
  • Type: string<binary>

    Example: example

  • Type: string<binary>[]

    Max items: 16

    Example
    [
              "example"
            ]
            

The image(s) to edit. Must be a supported image file or an array of images.

Example: example

prompt

Type: string

A text description of the desired image(s).

Example: A cute baby sea otter wearing a beret

background

Type: string | null

Allows to set transparency for the background of the generated image(s).

Default: auto

Enum: transparent, opaque, auto

input_fidelity

Any of 2 types
  • Type: InputFidelity

    Control how much effort the model will exert to match the style and features, especially facial features, of input images.
    Supports high and low. Defaults to low.

    Enum: high, low

  • Type: null

    Example: null

Example: high

mask

Type: string<binary>

An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where image should be edited.

Example: example

model

Any of 1 type
  • Type: string

    Example: example

The model to use for image generation.

Example: example

n

Type: integer | null

The number of images to generate. Must be between 1 and 10.

Default: 1

Min value: 1

Max value: 10

output_compression

Type: integer | null

The compression level (0-100%) for the generated images.

Default: 100

output_format

Type: string | null

The format in which the generated images are returned.Must be one of png, jpeg, or webp.
The default value is png.

Default: png

Enum: png, jpeg, webp

partial_images

Type: PartialImages

Example: 1

quality

Type: string | null

The quality of the image that will be generated. Defaults to auto.

Default: auto

Enum: standard, low, medium, high, auto

response_format

Type: string | null

The format in which the generated images are returned. Must be one of url or b64_json. URLs are only valid for 60 minutes after the image has been generated.

Enum: url, b64_json

size

Type: string | null

The size of the generated images. Must be one of 1024x1024, 1536x1024 (landscape), or 1024x1536 (portrait).

Default: 1024x1024

Enum: 1024x1024, 1536x1024, 1024x1536

stream

Type: boolean | null

Edit the image in streaming mode. Defaults to false.

Default: false

user

Type: string

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

Example: example

InputFidelity

Control how much effort the model will exert to match the style and features, especially facial features, of input images.
Supports high and low. Defaults to low.

Type: string

Enum: high, low

PartialImages

Any of 2 types
  • Type: integer

    The number of partial images to generate. This parameter is used for streaming responses that return partial images. Value must be between 0 and 3. When set to 0, the response will be a single image sent in one streaming event.

    Note that the final image may be sent before the full number of partial images are generated if the full image is generated more quickly.

    Default: 0

    Min value: 0

    Max value: 3

  • Type: null

    Example: null

Example: 1

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_edit.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: ImageEditPartialImageEvent

    Emitted when a partial image is available during image editing streaming.

    Example
    {
              "type": "image_edit.partial_image",
              "b64_json": "example",
              "created_at": 0,
              "size": "1024x1024",
              "quality": "low",
              "background": "transparent",
              "output_format": "png",
              "partial_image_index": 0
            }
            
  • Type: ImageEditCompletedEvent

    Emitted when image editing has completed and the final image is available.

    Example
    {
              "type": "image_edit.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
                }
              }
            }
            

ImageEditPartialImageEvent

Emitted when a partial image is available during image editing 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 edited 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 edited 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 edited image.

Enum: low, medium, high, auto

size

Type: string

The size of the requested edited image.

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

type

Type: string

The type of the event. Always image_edit.partial_image.

Const: image_edit.partial_image

Example: example

Example
{
          "type": "image_edit.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
          }
        }
        

ImageEditCompletedEvent

Emitted when image editing has completed and the final image is available.

Name

Description

b64_json

Type: string

Base64-encoded final edited image data, suitable for rendering as an image.

Example: example

background

Type: string

The background setting for the edited 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 edited image.

Enum: png, webp, jpeg

quality

Type: string

The quality setting for the edited image.

Enum: low, medium, high, auto

size

Type: string

The size of the edited image.

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

type

Type: string

The type of the event. Always image_edit.completed.

Const: image_edit.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_edit.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
            }
          }
        }
        
Предыдущая
Следующая