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
The image(s) to edit. Must be a supported image file or an array of images. Example: |
|
prompt |
Type: string A text description of the desired image(s). Example: |
|
background |
Type: string | null Allows to set transparency for the background of the generated image(s). Default: Enum: |
|
input_fidelity |
Any of 2 types
Example: |
|
mask |
Type: string<binary> An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where Example: |
|
model |
Any of 1 type
The model to use for image generation. Example: |
|
n |
Type: integer | null The number of images to generate. Must be between 1 and 10. Default: Min value: Max value: |
|
output_compression |
Type: integer | null The compression level (0-100%) for the generated images. Default: |
|
output_format |
Type: string | null The format in which the generated images are returned.Must be one of Default: Enum: |
|
partial_images |
Type: PartialImages Example: |
|
quality |
Type: string | null The quality of the image that will be generated. Defaults to Default: Enum: |
|
response_format |
Type: string | null The format in which the generated images are returned. Must be one of Enum: |
|
size |
Type: string | null The size of the generated images. Must be one of Default: Enum: |
|
stream |
Type: boolean | null Edit the image in streaming mode. Defaults to Default: |
|
user |
Type: string A unique identifier representing your end-user, which can help AI Studio to monitor and detect abuse. 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:
0Min value:
0Max 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 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_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: |
|
background |
Type: string The background setting for the requested edited image. Enum: |
|
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: |
|
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: |
|
size |
Type: string The size of the requested edited image. Enum: |
|
type |
Type: string The type of the event. Always Const: 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
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
}
}
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: |
|
background |
Type: string The background setting for the edited image. Enum: |
|
created_at |
Type: integer The Unix timestamp when the event was created. |
|
output_format |
Type: string The output format for the edited image. Enum: |
|
quality |
Type: string The quality setting for the edited image. Enum: |
|
size |
Type: string The size of the edited 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_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
}
}
}