XRToken API Docs

Edit image (image-to-image)

API Configuration
After saving, the Try It panel below sends real requests with this key.
Base: api.xrtoken.ai

Generate a new image from reference images and a text prompt using OpenAI-standard multipart/form-data binary uploads. Use repeated image[] fields for multiple uploads, or image for one upload. Use image_urls or image_urls[] for URLs. Decomposition requires exactly one reference through exactly one of these four entry points; do not combine them. Billing matches /v1/images/generations: token-billed models settle on usage.input_tokens / output_tokens, and per-image models settle on successful output images.

Seedream 5.0 Pro / Flash layer decomposition

Select a Seedream 5.0 Pro / Flash model that supports layers, and send layer_decomposition: true with exactly one input image. Layer decomposition accepts only PNG or JPEG input images, including uploaded files and Base64 data URIs. Omit prompt to identify the main elements automatically, or specify which elements to separate. Regular image generation still requires prompt. Layer decomposition accepts size values auto (default), 1K, 1.5K, and 2K; provide one input image and keep n at 1. The response contains one base image and up to 16 PNG layers with alpha channels. output_format controls only the base image; layers always use PNG. The data entries preserve z_index, name, description, and bounding_box. The base image has z_index=0; higher indices are placed above lower ones. bounding_box.absolute uses pixels in the output base image. normalized uses a 0–1000 scale. Both contain [left, top, right, bottom]. To reconstruct the image, resize each layer to its bounding box, place it at the upper-left corner, and stack layers in ascending z_index order. Layer files can have different dimensions from the base image. The base image and each successful output layer are billed separately by actual output resolution; n=1 does not limit billing to one image. This differs from sequential_image_generation batch generation, which 5.0 Pro does not support.

Seedream 5.0 Pro billing

Regular generation and layer decomposition are billed by actual output resolution. Each successful image is classified by its actual width × height: up to and including 2,610,000 pixels is the lower tier, and larger images use the higher tier. The base image counts as one output. Charge the base image and each successful layer separately by its own actual pixel tier; one request can contain both tiers. n=1 means one decomposition request, not a one-image charge. Only successful outputs are billed. Failed requests incur no charge and release the frozen amount. Pro's first reference image is free; references from the second onward are billed as input images. Reference fees per request are max(reference count − 1, 0) × your effective input rate, charged once and not multiplied by the output count. Output images are billed separately. Decomposition requires exactly one reference, so no input-image charge applies. Applicable account discounts affect both input and output rates. See the model pricing list on your current site for rates and applicable discounts.

The request examples below use the China endpoint. For International calls, use the corresponding endpoint and model ID.

curl https://api.xrtoken.net/v1/images/edits \
  -H "Authorization: Bearer $XRTOKEN_API_KEY" \
  -F "model=volcengine/doubao-seedream-5.0-pro" \
  -F "[email protected]" \
  -F "layer_decomposition=true" \
  -F "size=auto" \
  -F "response_format=url"
POST
/v1/images/edits

Authorization

BearerAuth
AuthorizationBearer <token>

API key authentication (OpenAI format). Pass in the Authorization header:

Authorization: Bearer tr-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

In: header

Request Body

multipart/form-data

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

curl -X post "https://api.xrtoken.ai/v1/images/edits" \  -F model="volcengine/doubao-seedream-5.0-pro" \  -F layer_decomposition="true"
{
  "created": 0,
  "data": [
    {
      "url": "http://example.com",
      "b64_json": "string",
      "size": "1273x265",
      "output_format": "string",
      "z_index": 0,
      "name": "string",
      "description": "string",
      "bounding_box": {
        "absolute": [
          383,
          120,
          1655,
          384
        ],
        "normalized": [
          187,
          59,
          808,
          188
        ]
      }
    }
  ],
  "usage": {
    "input_images": 0,
    "generated_images": 0,
    "input_tokens": 0,
    "output_tokens": 0,
    "total_tokens": 0
  }
}
{
  "error": "model field is required",
  "type": "invalid_request_error"
}
{
  "error": "invalid or missing API key",
  "type": "auth_error"
}
{
  "error": "insufficient balance -- please top up or upgrade your plan",
  "type": "billing_error"
}
{
  "error": "rate limit exceeded",
  "type": "rate_limit_error"
}
{
  "error": "upstream provider error",
  "type": "server_error"
}