Перейти к основному содержанию
POST
/
v1
/
images
/
edits
cURL
curl --request POST \
  --url https://api.ttapi.io/v1/images/edits \
  --header 'Content-Type: application/json' \
  --header 'TT-API-KEY: <api-key>' \
  --data '
{
  "prompt": "<string>",
  "image": "<array>",
  "mask": "<unknown>",
  "mode": "dall-e-2",
  "n": 123,
  "output_compression": "100",
  "quality": "auto",
  "response_format": "<string>",
  "size": "auto"
}
'
{
  "created": 1713833628,
  "data": [
    {
      "b64_json": "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABhWlDQ1BJQ0MgcHJvZmlsZQAAKJF9kT1Iw0AcxV9TpSItDnaQIpKhOlkQVFIwU8CR1NZBLi4iFg8B4R33PTK77Z22p22e+628923923f/jH53eV73923/..."
    }
  ],
  "usage": {
    "total_tokens": 100,
    "input_tokens": 50,
    "output_tokens": 50,
    "input_tokens_details": {
      "text_tokens": 10,
      "image_tokens": 40
    }
  }
}

Модели изображений OpenAI

Редактируйте или расширяйте изображения на основе одного или нескольких исходных изображений и промптов. Поддерживаются модели gpt-image-1 и dall-e-2.

Авторизации

TT-API-KEY
string
header
обязательно

Вы можете получить API-ключ в TTAPI Dashboard.

Тело

application/json
prompt
string
обязательно

Text description of the image. Maximum lengths: gpt-image-1 supports up to 32,000 characters, dall-e-2 supports up to 1,000 characters, dall-e-3 supports up to 4,000 characters.

image
array
обязательно

Image to edit. Must be a supported image file or image array.
gpt-image-1: each image should be a png, webp, or jpg file smaller than 25MB.
dall-e-2: you can only provide one image, and it should be a square png file smaller than 4MB.

mask
file

An additional image where fully transparent areas (e.g., Alpha value of zero) indicate where the image should be edited. If multiple images are provided, the mask applies to the first image. Must be a valid PNG file, smaller than 4MB, and the same dimensions as the image.

mode
enum<string>
по умолчанию:dall-e-2

Supported models

Доступные опции:
gpt-image-1,
dall-e-2
n
integer

Number of images to generate, default 1.
Available range 1-10

output_compression
integer
по умолчанию:100

Compression level for generated images (0-100%). This parameter only applies to gpt-image-1 with output format webp or jpeg, defaults to 100.

quality
string
по умолчанию:auto

Image quality.
auto (default) automatically selects the best quality for the given model.
gpt-image-1 supports three qualities: high, medium, low.
dall-e-3 supports hd and standard.
dall-e-2 only supports standard.

response_format
string

Return data format.
dall-e-3 and dall-e-2 support url or b64_json. URLs are valid for 60 minutes, so cache immediately after retrieval.
gpt-image-1 only supports b64_json.

size
string
по умолчанию:auto

Image size.
gpt-image-1 options: 1024x1024, 1536x1024, 1024x1536, auto (default).
dall-e-2 options: 256x256, 512x512, 1024x1024.
dall-e-3 options: 1024x1024, 1792x1024, 1024x1792.
Note: Different sizes consume different TTAPI quotas.

Ответ

Request successful, returns Base64 format image generation results

created
integer
обязательно

Generation timestamp (seconds)

Пример:

1713833628

data
object[]
обязательно

Image generation result list

usage
object
обязательно

Token usage (must return for Base64 format)

Пример:
{
"input_tokens": 50,
"input_tokens_details": { "image_tokens": 40, "text_tokens": 10 },
"output_tokens": 50,
"total_tokens": 100
}
Last modified on March 26, 2026