> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apistable.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Seedream 4.0 API

> Generate or edit images at 1K, 2K or 4K with one price across output resolutions.

## Parameters and input modes

`model` and `input` are required. Keep reference images accessible and unchanged until the task finishes.

For preset dimensions, use `resolution` and `aspect_ratio`. Supplying `size` as `widthxheight` sets the exact output dimensions and overrides both presets.

When using presets, `aspect_ratio: "auto"` matches a reference image and requires `image_urls`.

| Request type | Required input fields |
| - | - |
| Text to image | `prompt` |
| Image edit | `prompt` and a nonempty `image_urls` array. |
| Exact pixels | `prompt`, `size`, and `official_fallback: true`. |
| Related image set | `prompt`, `sequential_image_generation: "auto"`, and a nonempty `image_urls` array. |

## Use cases

```json Text to image theme={null}
{
  "model": "seedream-4-0",
  "input": {
    "prompt": "Studio photograph of a cobalt blue ceramic teapot, soft daylight, neutral background.",
    "resolution": "2K",
    "aspect_ratio": "16:9"
  }
}
```

```json Image edit theme={null}
{
  "model": "seedream-4-0",
  "input": {
    "prompt": "Replace the background with an ivory studio backdrop. Keep the teapot unchanged.",
    "image_urls": [
      "https://apistable.ai/models/seedream/seedream-5-5-teapot.png"
    ],
    "aspect_ratio": "auto"
  }
}
```

```json Generate at exact dimensions theme={null}
{
  "model": "seedream-4-0",
  "input": {
    "prompt": "Studio photograph of a cobalt blue ceramic teapot, soft daylight, neutral background.",
    "size": "2560x1440",
    "official_fallback": true
  }
}
```

```json Generate a related image set theme={null}
{
  "model": "seedream-4-0",
  "input": {
    "prompt": "Create four coordinated product photos of the same cobalt blue teapot, keeping its design and colors consistent.",
    "image_urls": [
      "https://apistable.ai/models/seedream/seedream-5-5-teapot.png"
    ],
    "sequential_image_generation": "auto",
    "sequential_image_generation_options": {
      "max_images": 4
    }
  }
}
```

## Playground and pricing

Each successful image is charged. Image sets reserve credits up to the output limit and settle by the number of images returned.

Exact pixel requests use the final fallback rate.

> [card] [Try in Playground](https://apistable.ai/models/seedream-4-0#try)
>
> Set your parameters and generate an image.

> [card] [View pricing](https://apistable.ai/models/seedream-4-0#pricing)
>
> Compare standard and fallback prices by resolution.


## OpenAPI

````yaml openapi-seedream-4-0.json POST /api/v1/tasks/create_task
openapi: 3.1.0
info:
  title: APIstable API
  version: 1.0.0-preview
  description: >-
    Public /api/v1 protocol. Valid API keys have the same account-scoped access.
    Read the selected model documentation for its ID, supported inputs, result
    format and availability before submitting. No client submission idempotency
    or max_credits. Availability, pricing, file retention and callback formats
    follow the selected model contract. Unconfigured operations return 503.
servers:
  - url: https://apistable.ai
    description: API Stable API
security: []
paths:
  /api/v1/tasks/create_task:
    post:
      summary: Seedream 4.0 API
      description: >-
        Generate or edit images at 1K, 2K or 4K with one price across output
        resolutions.
      operationId: seedream-4-0
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - model
                - input
              additionalProperties: false
              properties:
                model:
                  type: string
                  enum:
                    - seedream-4-0
                  example: seedream-4-0
                  description: The APIstable model ID for this endpoint.
                input:
                  $schema: https://json-schema.org/draft/2020-12/schema
                  type: object
                  properties:
                    layer_decomposition:
                      type: boolean
                      const: false
                    prompt:
                      type: string
                      minLength: 1
                      maxLength: 1000
                      description: Text instructions for generating or editing an image.
                    resolution:
                      default: 2K
                      description: >-
                        Resolution preset. Combine with an aspect ratio or
                        override it with `size`.
                      type: string
                      enum:
                        - 1K
                        - 2K
                        - 4K
                    aspect_ratio:
                      description: >-
                        `auto` matches a reference image and requires
                        `image_urls`. Fixed ratios also accept forms such as
                        `16x9`. Ignored when `size` is supplied.
                      default: '1:1'
                      anyOf:
                        - type: string
                          enum:
                            - auto
                            - '1:1'
                            - '4:3'
                            - '3:4'
                            - '16:9'
                            - '9:16'
                            - '3:2'
                            - '2:3'
                            - '21:9'
                            - '2:1'
                            - '1:2'
                            - '9:21'
                        - type: string
                          enum:
                            - 1x1
                            - 4x3
                            - 3x4
                            - 16x9
                            - 9x16
                            - 3x2
                            - 2x3
                            - 21x9
                            - 2x1
                            - 1x2
                            - 9x21
                    size:
                      description: >-
                        Exact pixels such as `2560x1440`. Use positive integers
                        separated by a lowercase x. Width × height must be
                        921,600–16,777,216 pixels, and width ÷ height must be
                        1/16–16. Overrides both presets. Requires
                        `official_fallback: true`.
                      type: string
                      pattern: ^\d{1,7}x\d{1,7}$
                    image_urls:
                      default: []
                      description: >-
                        Up to 14 public HTTP(S) images or supported Base64 data
                        URIs. Use JPEG or PNG. The JSON request body limit is
                        64,000 bytes.
                      maxItems: 14
                      type: array
                      items:
                        anyOf:
                          - type: string
                            pattern: >-
                              ^[Hh][Tt][Tt][Pp][Ss]?:\/\/[^/?#@\s\\]+(?:[/?][^#\s\\]*)?$
                          - type: string
                            pattern: >-
                              ^data:image\/(jpeg|png);base64,((?=[A-Za-z0-9+/])(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?)$
                    optimize_prompt:
                      default: false
                      description: >-
                        Refine the wording of the prompt before generating the
                        image.
                      type: boolean
                    sequential_image_generation:
                      type: string
                      enum:
                        - disabled
                        - auto
                      description: >-
                        Use `auto` to generate a related image set. The default
                        is one image.
                    sequential_image_generation_options:
                      type: object
                      properties:
                        max_images:
                          type: integer
                          minimum: 1
                          maximum: 15
                          description: >-
                            Maximum number of outputs. The model may return
                            fewer.
                      required:
                        - max_images
                      additionalProperties: false
                      description: >-
                        Image-set mode only. The output limit plus the reference
                        count cannot exceed 15. If omitted, the limit is 15
                        minus the reference count.
                    watermark:
                      description: Add a visible watermark. Off by default.
                      type: boolean
                    official_fallback:
                      default: false
                      description: Allow the final fallback tier.
                      type: boolean
                    nsfw_check:
                      default: false
                      description: >-
                        Screen the prompt and references before accepting the
                        task.
                      type: boolean
                  required:
                    - prompt
                  additionalProperties: false
                  allOf:
                    - if:
                        properties:
                          aspect_ratio:
                            const: auto
                        required:
                          - aspect_ratio
                        not:
                          required:
                            - size
                      then:
                        properties:
                          image_urls:
                            minItems: 1
                        required:
                          - image_urls
                    - if:
                        required:
                          - size
                      then:
                        properties:
                          official_fallback:
                            const: true
                        required:
                          - official_fallback
                    - if:
                        properties:
                          sequential_image_generation:
                            const: auto
                        required:
                          - sequential_image_generation
                      then:
                        properties:
                          image_urls:
                            minItems: 1
                        required:
                          - image_urls
                      else:
                        not:
                          required:
                            - sequential_image_generation_options
                callback_url:
                  type: string
                  format: uri
                  description: >-
                    Optional public HTTPS endpoint for signed completion
                    callbacks; no redirects or private IPs.
            example:
              model: seedream-4-0
              input:
                prompt: >-
                  Studio photograph of a cobalt blue ceramic teapot, soft
                  daylight, neutral background.
                resolution: 2K
                aspect_ratio: '16:9'
      responses:
        '200':
          description: >-
            Accepted task. Use `task_id` to [query the task](/query-task), or
            receive the result at `callback_url`.
          content:
            application/json:
              schema:
                type: object
                required:
                  - code
                  - msg
                  - data
                additionalProperties: false
                properties:
                  code:
                    const: 200
                    type: integer
                  msg:
                    const: success
                    type: string
                  data:
                    type: object
                    required:
                      - task_id
                    additionalProperties: false
                    properties:
                      task_id:
                        type: string
                        format: uuid
                        description: Task ID used to query the result.
              example:
                code: 200
                msg: success
                data:
                  task_id: 00000000-0000-4000-8000-000000000001
        '400':
          description: >-
            40001 invalid JSON, 40002 invalid input/callback or input rejected
            by screening, 40003 unsupported parameter.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Invalid or revoked API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '402':
          description: '40201: Insufficient credits (live acceptance).'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: '40301: Website session requests require the APIstable site origin.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: '40401: Unknown model or resource not found in this account.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: '40901: Resource incompatible with this operation.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '410':
          description: '41001: Source audio or temporary resource has expired.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '413':
          description: '41301: Request too large.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: '42201: Requested capability combination is not enabled.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: '42901: Rate/concurrency limit (live acceptance).'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: '50301: Service unavailable. No live submission or charge.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      callbacks:
        Webhook:
          '{$request.body#/callback_url}':
            post:
              requestBody:
                required: true
                description: >-
                  When the task succeeds or fails, APIstable sends a JSON POST
                  to the `callback_url` supplied at creation. Verify the
                  signature and return HTTP 2xx to acknowledge delivery.


                  Read `data.status` to determine the generation outcome.
                  Partial success also reports `succeeded`. `data.result.urls`
                  lists successful images, which are retained for 14 days. For a
                  failed task, `data.result` is `null` and `data.message`
                  contains the failure reason.


                  Use `X-APIstable-Signature`, `X-APIstable-Timestamp`, and
                  `X-APIstable-Event-Id` to verify and deduplicate deliveries.
                  See [Webhook security](/webhook-secret).


                  **Webhook payload example**


                  ```json

                  {
                    "code": 200,
                    "msg": "success",
                    "data": {
                      "task_id": "00000000-0000-4000-8000-000000000001",
                      "model": "seedream-4-0",
                      "status": "succeeded",
                      "created_at": "2026-11-13T08:30:00.000Z",
                      "completed_at": "2026-11-13T08:30:08.000Z",
                      "duration": 8000,
                      "charged_credits": 5,
                      "message": "",
                      "input": "{\"prompt\":\"Studio photograph of a cobalt blue teapot.\",\"resolution\":\"2K\"}",
                      "result": {
                        "urls": [
                          "https://cdn.example.com/generated/image.jpg"
                        ],
                        "items": [
                          {
                            "id": "00000000-0000-4000-8000-000000000002",
                            "status": "succeeded",
                            "charged_credits": 5,
                            "urls": [
                              "https://cdn.example.com/generated/image.jpg"
                            ]
                          }
                        ]
                      }
                    }
                  }

                  ```
                content:
                  application/json:
                    schema:
                      type: object
                      required:
                        - code
                        - msg
                        - data
                      properties:
                        code:
                          const: 200
                          type: integer
                        msg:
                          const: success
                          type: string
                        data:
                          type: object
                          additionalProperties: false
                          required:
                            - task_id
                            - model
                            - status
                            - created_at
                            - completed_at
                            - duration
                            - charged_credits
                            - message
                            - input
                            - result
                          properties:
                            task_id:
                              type: string
                            model:
                              type: string
                              const: seedream-4-0
                            status:
                              type: string
                              enum:
                                - succeeded
                                - failed
                            created_at:
                              type: string
                              format: date-time
                            completed_at:
                              type:
                                - string
                                - 'null'
                              format: date-time
                            duration:
                              type:
                                - integer
                                - 'null'
                              minimum: 0
                              description: >-
                                Total elapsed milliseconds; null while
                                processing.
                            charged_credits:
                              type:
                                - number
                                - 'null'
                              minimum: 0
                              description: Final charged Credits; null until completion.
                            message:
                              type: string
                              description: >-
                                Failure reason for failed tasks, or an
                                actionable pending-settlement message while
                                processing; empty on success.
                            input:
                              type: string
                              contentMediaType: application/json
                              description: JSON-serialized accepted model input.
                            result:
                              type:
                                - object
                                - 'null'
                              required:
                                - urls
                                - items
                              properties:
                                urls:
                                  type: array
                                  maxItems: 100
                                  items:
                                    type: string
                                    format: uri
                                items:
                                  type: array
                                  maxItems: 4
                                  items:
                                    type: object
                                    required:
                                      - id
                                      - status
                                      - charged_credits
                                      - urls
                                    properties:
                                      id:
                                        type: string
                                        format: uuid
                                      status:
                                        type: string
                                      charged_credits:
                                        type: number
                                        minimum: 0
                                      urls:
                                        type: array
                                        items:
                                          type: string
                                          format: uri
                    example:
                      code: 200
                      msg: success
                      data:
                        task_id: 00000000-0000-4000-8000-000000000001
                        model: seedream-4-0
                        status: succeeded
                        created_at: '2026-11-13T08:30:00.000Z'
                        completed_at: '2026-11-13T08:30:08.000Z'
                        duration: 8000
                        charged_credits: 5
                        message: ''
                        input: >-
                          {"prompt":"Studio photograph of a cobalt blue
                          teapot.","resolution":"2K"}
                        result:
                          urls:
                            - https://cdn.example.com/generated/image.jpg
                          items:
                            - id: 00000000-0000-4000-8000-000000000002
                              status: succeeded
                              charged_credits: 5
                              urls:
                                - https://cdn.example.com/generated/image.jpg
              responses:
                2XX:
                  description: Webhook acknowledged.
              method: post
              type: path
            path: '{$request.body#/callback_url}'
      security:
        - bearerAuth: []
components:
  schemas:
    Error:
      type: object
      required:
        - code
        - msg
        - data
      properties:
        code:
          type: integer
        msg:
          type: string
        data:
          type: 'null'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Sign in to APIstable, then create and copy a key from [API Key
        management](https://apistable.ai/console/keys).


        Send this HTTP header with every request:


        ```http

        Authorization: Bearer YOUR_API_KEY

        ```


        Replace YOUR_API_KEY with the key you created.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.