{
  "openapi": "3.1.0",
  "info": {
    "title": "Seedream asynchronous image task API",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.cometapi.com"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/v1/images/generations": {
      "post": {
        "summary": "Create a Seedream image task",
        "operationId": "bytedance_image_generation",
        "description": "Submit a Seedream asynchronous image task. Store `data.task_id`, then poll `GET /v1/images/generations/{task_id}`.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "prompt",
                  "async"
                ],
                "properties": {
                  "model": {
                    "type": "string",
                    "description": "Seedream model ID. This async workflow is documented for `doubao-seedream-4-0-250828`, `doubao-seedream-4-5-251128`, `doubao-seedream-5-0-260128`, and `seedream-5-0-pro-260628`. Query `/v1/models` or open the [Models page](/overview/models) for account availability.",
                    "example": "doubao-seedream-5-0-260128"
                  },
                  "prompt": {
                    "type": "string",
                    "description": "Text prompt describing the image to generate.",
                    "example": "A clean studio photograph of a small red ceramic teapot on a pale blue table, soft window light, no text."
                  },
                  "size": {
                    "type": "string",
                    "description": "Requested output size. Use a value supported by the selected model.",
                    "example": "2K"
                  },
                  "response_format": {
                    "type": "string",
                    "description": "Response workflow for this async request. The example uses `url` and retrieves the URL from the completed task.",
                    "example": "url"
                  },
                  "watermark": {
                    "type": "boolean",
                    "description": "Whether to request a visible watermark on the generated image.",
                    "example": false
                  },
                  "async": {
                    "type": "boolean",
                    "description": "Asynchronous task mode. Set this to `true`, store `data.task_id`, and poll the task endpoint.",
                    "const": true
                  }
                }
              },
              "examples": {
                "Async text to image (Seedream 5.0 Lite)": {
                  "summary": "Submit an asynchronous Seedream 5.0 Lite task",
                  "value": {
                    "model": "doubao-seedream-5-0-260128",
                    "prompt": "A clean studio photograph of a small red ceramic teapot on a pale blue table, soft window light, no text.",
                    "size": "2K",
                    "response_format": "url",
                    "watermark": false,
                    "async": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Seedream asynchronous task submission response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "string",
                      "description": "Request status code. A successful submission returns `success`.",
                      "example": "success"
                    },
                    "message": {
                      "type": "string",
                      "description": "Status message. A successful submission can return an empty string."
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "task_id",
                        "status",
                        "data"
                      ],
                      "properties": {
                        "task_id": {
                          "type": "string",
                          "description": "Task ID to pass to `GET /v1/images/generations/{task_id}`."
                        },
                        "status": {
                          "type": "string",
                          "description": "Task state at submission time.",
                          "enum": [
                            "pending",
                            "success",
                            "failure"
                          ]
                        },
                        "data": {
                          "type": "array",
                          "description": "Empty at submission time. Poll the task endpoint for final image data.",
                          "items": {
                            "type": "object"
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "code": "success",
                  "message": "",
                  "data": {
                    "task_id": "<task_id>",
                    "status": "pending",
                    "data": []
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "Async text to image (Seedream 5.0 Lite)",
            "source": "curl https://api.cometapi.com/v1/images/generations \\\n  -H \"Authorization: Bearer $COMETAPI_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"model\": \"doubao-seedream-5-0-260128\",\n    \"prompt\": \"A clean studio photograph of a small red ceramic teapot on a pale blue table, soft window light, no text.\",\n    \"size\": \"2K\",\n    \"response_format\": \"url\",\n    \"watermark\": false,\n    \"async\": true\n  }'\n"
          },
          {
            "lang": "Python",
            "label": "Async text to image (Seedream 5.0 Lite)",
            "source": "import os\nimport requests\n\nresponse = requests.post(\n    \"https://api.cometapi.com/v1/images/generations\",\n    headers={\n        \"Authorization\": \"Bearer \" + os.environ[\"COMETAPI_KEY\"],\n        \"Content-Type\": \"application/json\",\n    },\n    json={\n        \"model\": \"doubao-seedream-5-0-260128\",\n        \"prompt\": \"A clean studio photograph of a small red ceramic teapot on a pale blue table, soft window light, no text.\",\n        \"size\": \"2K\",\n        \"response_format\": \"url\",\n        \"watermark\": False,\n        \"async\": True,\n    },\n    timeout=60,\n)\nresponse.raise_for_status()\nprint(response.json()[\"data\"][\"task_id\"])\n"
          },
          {
            "lang": "JavaScript",
            "label": "Async text to image (Seedream 5.0 Lite)",
            "source": "const response = await fetch(\"https://api.cometapi.com/v1/images/generations\", {\n  method: \"POST\",\n  headers: {\n    Authorization: `Bearer ${process.env.COMETAPI_KEY}`,\n    \"Content-Type\": \"application/json\",\n  },\n  signal: AbortSignal.timeout(60_000),\n  body: JSON.stringify({\n    model: \"doubao-seedream-5-0-260128\",\n    prompt: \"A clean studio photograph of a small red ceramic teapot on a pale blue table, soft window light, no text.\",\n    size: \"2K\",\n    response_format: \"url\",\n    watermark: false,\n    async: true,\n  }),\n});\n\nif (!response.ok) throw new Error(await response.text());\nconst task = await response.json();\nconsole.log(task.data.task_id);\n"
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Bearer token authentication. Use your CometAPI key."
      }
    }
  }
}
