Developer Docs/Text to Image API

Text to Image API

Build Text to Image integrations with A2E. Review authentication, request parameters, task creation, status, and result endpoints.

Overview

Generate images from natural language prompts using the platform's diffusion model pipeline. Describe what you want - style, composition, lighting - and receive high-resolution results.

Primary Endpoint

POST/api/v1/userText2Image/start

Create one or more asynchronous text-to-image tasks, then return the records used to monitor generated images. Select the image model with `model_type`: - `a2e`: auto-select the default image model. It supports text-to-image and image editing with up to two reference images. - `a2e-v2`: use the V2 image algorithm with the same inputs, output count, pricing, and access rules as `a2e`. It accepts up to two reference images; legacy `1K` requests are billed and generated as `1080P`. - `zimage`: Z-Image Turbo for text-to-image generation. It does not accept reference images. - `seedream`: the Seedream image generation and editing family. Set `model_version` to `4.5`, `5.0`, `5.0-pro`, or `5.5`; Seedream 5.0 Pro and 5.5 accept up to ten reference images, while 4.5 and 5.0 accept up to two. On CN sites, pure text-to-image requests for both `a2e` and `a2e-v2` use Z-Image and its provider content inspection. Seedream 5.5 supports `background` (auto/transparent/opaque), `output_format` (PNG/JPEG), and optional layer decomposition from exactly one input image. Transparent backgrounds require PNG. A layer request omits `background`, returns one base image and up to 99 transparent PNG layers, and may request OCR metadata. The response includes every layer's URL, order, position and optional recognized text. API clients should normally set concrete output dimensions with `width` and `height`. The optional `aspect_ratio` and `resolution` fields are also accepted and validated by this endpoint (an unsupported value returns 400), and both are echoed back in the task records, so they are part of the public request contract. For Seedream 5.0 Pro `aspect_ratio` takes precedence over `width`/`height`, and when it is omitted the backend falls back to `9:16`. Actual media size, dimensions, duration, format and applicable frame-rate limits are checked against the selected provider interface before charging or creating any task. Client metadata is not authoritative. Invalid or unreadable media returns HTTP 400 with the failing field, measured value and expected range; direct API requests are not automatically resized or transcoded and do not inherit lower website upload limits. Media inspection errors preserve HTTP status and business code: 400 INVALID_MEDIA for confirmed invalid media, 400 MEDIA_RESOURCE_UNAVAILABLE for inaccessible or expired sources, 400 MEDIA_PROBE_LIMIT for the server source inspection budget, 429 MEDIA_PROBE_BUSY for local queue saturation, 503 MEDIA_PROBE_UNAVAILABLE for transient network/upstream failures, 504 MEDIA_PROBE_TIMEOUT for inspection timeouts, and 500 MEDIA_PROBE_FAILED for internal processing failures. All media checked for this request share a 280-second deadline, including queueing, Range probing and full-download fallback. Even valid assets can exceed this processing deadline. Timeout cancels remaining inspection and cleanup completes before returning; no automatic retry, charge, task creation or generation-provider submission occurs on failed inspection. ### Request - Send a valid bearer token. The server evaluates the operation in the authenticated caller's access context. - Send an `application/json` body. Required fields: `prompt`. - API-token callers may include `webhook_url` and `webhook_token` for best-effort terminal-state notifications; ordinary JWT/cookie calls ignore these fields. ### Behavior - This is an asynchronous operation: a successful submission creates a task and returns before processing finishes. - Persist the returned task identifier and use the corresponding detail or list operation to observe progress. - Treat the detail endpoint as the source of truth even when webhook delivery is enabled. ### Response - A `200` response confirms task acceptance; it does not by itself mean media generation has completed. - Retain the returned identifier and wait for a documented terminal status before using output URLs. - JSON object responses, including error responses, normally carry a top-level `trace_id` string for this request; include it when contacting support. It is not a task identifier. - Do not infer undocumented fields or statuses; clients should tolerate additional response properties. ### Errors - `400` — Bad Request - Invalid parameters. - `401` — Unauthorized - Invalid or missing JWT token. - `422` — Content moderation rejected the `input_images`. Code `1003` means confirmed minor content. Code `1004` means suspected minor content. For `1004`, confirm the input and retry with `minor_suspected_skip: true`. - `429` — MEDIA_PROBE_BUSY - Local media inspection queue is full or its wait deadline elapsed. - `500` — MEDIA_PROBE_FAILED - Internal media inspection failure; not a media specification violation. - `503` — MEDIA_PROBE_UNAVAILABLE - Transient network or upstream failure; retry is allowed. - `504` — MEDIA_PROBE_TIMEOUT - Media connection, download, inspection or the shared 280-second request inspection deadline elapsed; retry is allowed. This is a processing timeout, not a media specification violation. ### Related Operations - `GET /api/v1/userText2Image/allRecords` — Get all text to image records. - `GET /api/v1/userText2Image/{_id}` — Get text to image record detail. - `DELETE /api/v1/userText2Image/{_id}` — Delete task. Authentication: set header Authorization: Bearer <token> (supports user JWT or sk_ API token).

Request Parameters

NameTypeRequiredDescription
ai_sharing_consentobjectNoConsent receipt for newer native apps. Legacy native requests may omit this field and continue without a consent record. If present, null, malformed, expired or incomplete receipts return AI_SHARING_CONSENT_REQUIRED before generation. Valid receipts cover all actual AI recipients, including safety providers and intermediaries, and constrain later fallback. Content safety checks remain required for native requests. Web and legacy API behavior is unchanged. The recipient example below is for the default A2E model. When supplied, Seedream receipts must also include ByteDance; see the native_seedream request example.
ai_sharing_consent.versionenum: 2026-11-12Yes-
ai_sharing_consent.recipientsarray<string>Yes-
namestringNoName of the text to image task (optional, auto-generated if not provided)
promptstringYesText prompt for image generation
creation_modeenum: text-to-image | image-editNoOptional compatibility field for history and mode reporting; callers may omit it. The server ignores any supplied value and records `image-edit` when `input_images` contains a valid HTTP(S) image URL, otherwise `text-to-image`. It is not forwarded to the model provider.
widthnumberNoImage width. When omitted, Seedream 5.5 uses 1024 / 1536 / 2048 for 1K / 1.5K / 2K (2K if resolution is omitted); other models default to 1024. Explicit dimensions remain available for automatic aspect ratio. `a2e-v2` rounds fractional values to the nearest integer before pricing and submission.
heightnumberNoImage height. When omitted, uses the same model and resolution dependent default as width. `a2e-v2` rounds fractional values to the nearest integer before pricing and submission.
model_typeenum: a2e | a2e-v2 | zimage | seedreamNoModel type to use for generation. Use `a2e` for the default model or `a2e-v2` for the V2 algorithm.; default: "a2e"
model_versionenum: 4.5 | 5.0 | 5.0-pro | 5.5NoSeedream model version. Required to select Seedream 4.5, 5.0, 5.0 Pro, or 5.5 when model_type is seedream.; default: "4.5"
input_imagesarray<string>NoReference images for A2E V1/V2 or Seedream. A2E V1/V2, Seedream 4.5, and Seedream 5.0 support at most 2 images; Seedream 5.0 Pro and 5.5 support at most 10.; maxItems: 10
skip_face_enhancebooleanNoV1 only. Whether to disable face similarity enhancement. Ignored for `a2e-v2`; the V2 algorithm does not use this parameter.; default: false
aspect_ratioenum: 1:1 | 4:3 | 3:4 | 16:9 | 9:16 | 2:3 | 3:2 | 21:9NoOutput aspect ratio for the Seedream family. Rejected with 400 when the value is outside this enum. Seedream 5.0 Pro resolves the size from this ratio first and only falls back to `width`/`height` when it is absent, and the backend defaults it to `9:16` for Seedream requests that omit it.
resolutionenum: auto | 1K | 1080P | 1.5K | 2K | 3K | 4KNoOutput resolution tier. Rejected with 400 when the value is outside this enum. The billed tier is the higher of this value and the tier inferred from the short side of `width`/`height`, so a large `width`/`height` cannot be billed as a lower tier. `a2e` and `zimage` only have `1K`, `1080P`, and `2K`; `3K`/`4K` are treated as `2K` for them. For Seedream 5.0 Pro the output size comes from `aspect_ratio` plus this tier, so `width`/`height` never raise an explicitly requested tier there. Effective tiers per Seedream version: `5.0-pro` distinguishes only `1K` and `2K` and treats every other value as `2K`; `4.5` serves `2K`/`4K`; `5.0` serves `2K`/`3K`; `5.5` accepts `1K`/`1.5K`/`2K` and defaults to `2K`. Seedream 5.5 layer decomposition additionally accepts `auto`, which is charged at the 2K tier without reconciliation for fewer layers or smaller output sizes; ordinary generation rejects `auto`.
max_imagesintegerNoMaximum number of images to generate (creates multiple tasks internally). Seedream 5.5 permits up to 9; other models permit up to 8.; minimum: 1; maximum: 9
backgroundenum: auto | transparent | opaqueNoSeedream 5.5 only. Omit for layer decomposition; transparent is incompatible with JPEG.; default: "auto"
output_formatenum: png | jpegNoSeedream 5.5 only. For layer decomposition this sets the base image format; layers remain transparent PNG.; default: "png"
layer_decomposition_optionsobjectNoSeedream 5.5 only. Requires exactly one input image and no background field. Returns one base image and up to 99 transparent PNG layers as result images.
layer_decomposition_options.max_imagesintegerNoMaximum number of images including the base image. Charged at this upper limit; fewer returned images do not receive a partial refund.; minimum: 2; maximum: 100; default: 5
layer_decomposition_options.text_recognitionbooleanNoInclude editable text metadata for supported regular fonts.; default: false
minor_suspected_skipbooleanNoConfirm retry after the suspected-minor soft block; hard blocks remain enforced.; default: false
webhook_urlstringNoHTTPS URL to receive task.completed / task.failed notifications. Best-effort delivery, single attempt, no retries; clients should treat the detail API as the source of truth.; maxLength: 2048
webhook_tokenstringNoOptional plaintext token returned in the X-A2e-Webhook-Token header so receivers can verify the request originated from a2e.; maxLength: 256
Request schema and conditional rules
{
  "allOf": [
    {
      "type": "object",
      "properties": {
        "ai_sharing_consent": {
          "type": "object",
          "description": "Consent receipt for newer native apps. Legacy native requests may omit this field and continue without a consent record. If present, null, malformed, expired or incomplete receipts return AI_SHARING_CONSENT_REQUIRED before generation. Valid receipts cover all actual AI recipients, including safety providers and intermediaries, and constrain later fallback. Content safety checks remain required for native requests. Web and legacy API behavior is unchanged. The recipient example below is for the default A2E model. When supplied, Seedream receipts must also include ByteDance; see the native_seedream request example.",
          "required": [
            "version",
            "recipients"
          ],
          "properties": {
            "version": {
              "type": "string",
              "enum": [
                "2026-11-12"
              ]
            },
            "recipients": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": [
                "A2E",
                "Alibaba Cloud"
              ]
            }
          }
        },
        "name": {
          "type": "string",
          "description": "Name of the text to image task (optional, auto-generated if not provided)",
          "example": "My Generated Image"
        },
        "prompt": {
          "type": "string",
          "description": "Text prompt for image generation",
          "example": "A beautiful sunset over mountains"
        },
        "creation_mode": {
          "type": "string",
          "enum": [
            "text-to-image",
            "image-edit"
          ],
          "description": "Optional compatibility field for history and mode reporting; callers may omit it. The server ignores any supplied value and records `image-edit` when `input_images` contains a valid HTTP(S) image URL, otherwise `text-to-image`. It is not forwarded to the model provider."
        },
        "width": {
          "type": "number",
          "description": "Image width. When omitted, Seedream 5.5 uses 1024 / 1536 / 2048 for 1K / 1.5K / 2K (2K if resolution is omitted); other models default to 1024. Explicit dimensions remain available for automatic aspect ratio. `a2e-v2` rounds fractional values to the nearest integer before pricing and submission.",
          "example": 1024
        },
        "height": {
          "type": "number",
          "description": "Image height. When omitted, uses the same model and resolution dependent default as width. `a2e-v2` rounds fractional values to the nearest integer before pricing and submission.",
          "example": 1024
        },
        "model_type": {
          "type": "string",
          "description": "Model type to use for generation. Use `a2e` for the default model or `a2e-v2` for the V2 algorithm.",
          "enum": [
            "a2e",
            "a2e-v2",
            "zimage",
            "seedream"
          ],
          "default": "a2e",
          "example": "a2e"
        },
        "model_version": {
          "type": "string",
          "description": "Seedream model version. Required to select Seedream 4.5, 5.0, 5.0 Pro, or 5.5 when model_type is seedream.",
          "enum": [
            "4.5",
            "5.0",
            "5.0-pro",
            "5.5"
          ],
          "default": "4.5",
          "example": "5.0-pro"
        },
        "input_images": {
          "type": "array",
          "description": "Reference images for A2E V1/V2 or Seedream. A2E V1/V2, Seedream 4.5, and Seedream 5.0 support at most 2 images; Seedream 5.0 Pro and 5.5 support at most 10.",
          "items": {
            "type": "string"
          },
          "maxItems": 10,
          "example": [
            "https://example.com/image1.jpg",
            "https://example.com/image2.jpg"
          ]
        },
        "skip_face_enhance": {
          "type": "boolean",
          "description": "V1 only. Whether to disable face similarity enhancement. Ignored for `a2e-v2`; the V2 algorithm does not use this parameter.",
          "default": false,
          "example": false
        },
        "aspect_ratio": {
          "type": "string",
          "description": "Output aspect ratio for the Seedream family. Rejected with 400 when the value is outside this enum.\nSeedream 5.0 Pro resolves the size from this ratio first and only falls back to `width`/`height` when it is absent, and the backend defaults it to `9:16` for Seedream requests that omit it.\n",
          "enum": [
            "1:1",
            "4:3",
            "3:4",
            "16:9",
            "9:16",
            "2:3",
            "3:2",
            "21:9"
          ],
          "example": "1:1"
        },
        "resolution": {
          "type": "string",
          "description": "Output resolution tier. Rejected with 400 when the value is outside this enum.\nThe billed tier is the higher of this value and the tier inferred from the short side of `width`/`height`, so a large `width`/`height` cannot be billed as a lower tier. `a2e` and `zimage` only have `1K`, `1080P`, and `2K`; `3K`/`4K` are treated as `2K` for them. For Seedream 5.0 Pro the output size comes from `aspect_ratio` plus this tier, so `width`/`height` never raise an explicitly requested tier there.\nEffective tiers per Seedream version: `5.0-pro` distinguishes only `1K` and `2K` and treats every other value as `2K`; `4.5` serves `2K`/`4K`; `5.0` serves `2K`/`3K`; `5.5` accepts `1K`/`1.5K`/`2K` and defaults to `2K`. Seedream 5.5 layer decomposition additionally accepts `auto`, which is charged at the 2K tier without reconciliation for fewer layers or smaller output sizes; ordinary generation rejects `auto`.\n",
          "enum": [
            "auto",
            "1K",
            "1080P",
            "1.5K",
            "2K",
            "3K",
            "4K"
          ],
          "example": "2K"
        },
        "max_images": {
          "type": "integer",
          "description": "Maximum number of images to generate (creates multiple tasks internally). Seedream 5.5 permits up to 9; other models permit up to 8.",
          "minimum": 1,
          "maximum": 9,
          "example": 1
        },
        "background": {
          "type": "string",
          "enum": [
            "auto",
            "transparent",
            "opaque"
          ],
          "default": "auto",
          "description": "Seedream 5.5 only. Omit for layer decomposition; transparent is incompatible with JPEG."
        },
        "output_format": {
          "type": "string",
          "enum": [
            "png",
            "jpeg"
          ],
          "default": "png",
          "description": "Seedream 5.5 only. For layer decomposition this sets the base image format; layers remain transparent PNG."
        },
        "layer_decomposition_options": {
          "type": "object",
          "description": "Seedream 5.5 only. Requires exactly one input image and no background field. Returns one base image and up to 99 transparent PNG layers as result images.",
          "properties": {
            "max_images": {
              "type": "integer",
              "minimum": 2,
              "maximum": 100,
              "default": 5,
              "description": "Maximum number of images including the base image. Charged at this upper limit; fewer returned images do not receive a partial refund."
            },
            "text_recognition": {
              "type": "boolean",
              "default": false,
              "description": "Include editable text metadata for supported regular fonts."
            }
          }
        },
        "minor_suspected_skip": {
          "type": "boolean",
          "default": false,
          "description": "Confirm retry after the suspected-minor soft block; hard blocks remain enforced."
        }
      },
      "required": [
        "prompt"
      ]
    },
    {
      "$ref": "#/components/schemas/WebhookInput"
    }
  ]
}

Response Fields

code: integer
Response code. 0 means success.
data: array<object>
Created text-to-image task records.
data[]._id: string
Task id.
data[].name: string
Task name.
data[].prompt: string
Generation prompt.
data[].current_status: string
Current task status.
data[].image_urls: array<string>
Generated image URLs.
data[].background: enum: auto | transparent | opaque |
Seedream 5.5 background setting, when present.
data[].output_format: enum: png | jpeg |
Seedream 5.5 base image format, when present.
data[].layer_decomposition_options: object
Seedream 5.5 layer request settings, when present.
data[].layer_images: array<object>
Seedream 5.5 base image and transparent layers, with their position, order, semantic metadata, and optional rich-text OCR.
data[].layer_images[].url: string
data[].layer_images[].size: string
data[].layer_images[].output_format: enum: png | jpeg
data[].layer_images[].background: enum: transparent | opaque
data[].layer_images[].z_index: integer
data[].layer_images[].bounding_box: object
data[].layer_images[].name: string
data[].layer_images[].description: string
data[].layer_images[].text_recognition: object
data[].width: number
Output image width.
data[].height: number
Output image height.
data[].coins: number
Credits charged for the task.
data[].hasRefundCoin: boolean
Stored refund flag; true does not confirm crediting while refund_pending is true. Omitted when unknown, including legacy records without a stored flag.
data[].refund_pending: boolean
True means refund pending resolution and takes precedence over hasRefundCoin. Explicit false is preserved; omitted when unknown, including legacy records without a stored flag.
trace_id: string
Trace ID of this HTTP request. Include it when contacting support about this request. It is generated per request and is not a task identifier; use the returned task `_id` to query results.

Request Example

curl -X POST "https://www.a2e.com.cn/api/v1/userText2Image/start" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "prompt": "A quiet mountain landscape",
  "model_type": "seedream",
  "model_version": "5.5",
  "ai_sharing_consent": {
    "version": "2026-11-12",
    "recipients": [
      "A2E",
      "Alibaba Cloud",
      "ByteDance"
    ]
  }
}'

Related Endpoints

Responses

200

Text to image task started successfully

400

Bad Request - Invalid parameters

401

Unauthorized - Invalid or missing bearer token

422

Content moderation rejected the `input_images`. Code `1003` means confirmed minor content. Code `1004` means suspected minor content. For `1004`, confirm the input and retry with `minor_suspected_skip: true`.

429

MEDIA_PROBE_BUSY - Local media inspection queue is full or its wait deadline elapsed.

500

MEDIA_PROBE_FAILED - Internal media inspection failure; not a media specification violation.

503

MEDIA_PROBE_UNAVAILABLE - Transient network or upstream failure; retry is allowed.

504

MEDIA_PROBE_TIMEOUT - Media connection, download, inspection or the shared 280-second request inspection deadline elapsed; retry is allowed. This is a processing timeout, not a media specification violation.

Text to Image API Documentation