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

# إنشاء تعديلات صور SeedEdit

> استخدم CometAPI POST /v1/images/edits لتحرير صور SeedEdit باستخدام مدخلات JSON، وعمليات الرفع multipart، والتعديلات الموجّهة عبر Prompt، مع أقنعة اختيارية.

استخدم مسار `POST /v1/images/edits` المتوافق مع OpenAI من CometAPI لتشغيل تحرير صور SeedEdit. تقبل نقطة النهاية هذه مراجع الصور بصيغة JSON أو عمليات رفع الملفات بنمط multipart، ويمكنها تطبيق تغييرات موجّهة عبر Prompt مع قناع اختياري.

للاطلاع على model ID المتاحة، راجع [صفحة Models](/ar/overview/models) أو استعلم عن `/v1/models`. ولمعرفة تفاصيل معلمات المزوّد، راجع [توثيق VolcEngine SeedEdit](https://www.volcengine.com/docs/82379/1666946).

## اختر شكل طلب التعديل

* تعديل JSON: أرسل `model` و`image` و`prompt` وعناصر تحكم اختيارية مثل `size` و`response_format` و`watermark`.
* رفع Multipart: أرسل الحقول نفسها كأجزاء form وارفع `image` كملف.
* تعديل باستخدام قناع: أضف `mask` كـ data URI أو عنوان URL عام عبر HTTPS أو ملف مرفوع. استخدم قناع PNG عالي التباين لتحديد منطقة التعديل.

<Note>
  استخدم `2K` أو `4K` أو `1K` أو قيمة `WIDTHxHEIGHT` يدعمها model من أجل `size`. احذف `size` عندما تريد القيمة الافتراضية للمسار.
</Note>

## أرسل مدخلات الصور

في طلبات JSON، استخدم `data:image/png;base64,YOUR_BASE64_IMAGE` أو عنوان URL عامًا عبر HTTPS يمكن للمزوّد جلبه. أما في طلبات multipart، فارفع `source.png` أو أي ملف صورة مدعوم آخر مباشرةً.

## اقرأ عناوين URL الناتجة

<Warning>
  القيمة `url` المُعادة هي رابط موقّع لتخزين الكائنات، وقد تحتوي على `&` و`%` ومحارف خاصة أخرى. استخرج عنوان URL من JSON بعد تحليله بدلًا من نسخ سطر جزئي من الطرفية. في أمثلة shell، يحافظ `jq -r '.data[]?.url'` على عنوان URL الموقّع بالكامل.
</Warning>


## OpenAPI

````yaml api/openapi/image/seededit-seedream/post-bytedance-image-editing.openapi.json POST /v1/images/edits
openapi: 3.1.0
info:
  title: SeedEdit image editing API
  version: 1.0.0
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /v1/images/edits:
    post:
      summary: Create SeedEdit image edits
      operationId: bytedance_image_editing
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              description: Parameters for SeedEdit image editing with JSON image inputs.
              required:
                - model
                - image
                - prompt
              properties:
                model:
                  type: string
                  description: >-
                    SeedEdit model ID to use. Query `/v1/models` or open the
                    [Models page](/overview/models) for available image editing
                    model IDs.
                  default: doubao-seededit-3-0-i2i-250628
                image:
                  type: string
                  description: >-
                    Source image to edit as a public HTTPS URL or a data URI
                    such as `data:image/png;base64,YOUR_BASE64_IMAGE`. Use JPEG
                    or PNG input and keep the file within the route size limit.
                  default: data:image/png;base64,YOUR_BASE64_IMAGE
                mask:
                  type: string
                  description: >-
                    Optional mask image as a public HTTPS URL or data URI. Use a
                    high-contrast PNG mask to mark the region that should
                    receive the edit.
                  default: data:image/png;base64,YOUR_BASE64_MASK
                prompt:
                  type: string
                  description: >-
                    Instruction describing the desired edit, such as `Change the
                    red square into a blue square and keep the background
                    unchanged`.
                  default: >-
                    Change the red square into a blue square and keep the
                    background unchanged.
                response_format:
                  type: string
                  description: >-
                    Response image format. Use `url` for a temporary signed
                    image URL, or `b64_json` when you need base64 image data in
                    the response.
                  default: url
                  enum:
                    - url
                    - b64_json
                size:
                  type: string
                  description: >-
                    Output resolution. Use a tier such as `1K`, `2K`, or `4K`,
                    or a model-supported `WIDTHxHEIGHT` value such as
                    `2048x2048`. Omit the field to use the route default.
                  default: 2K
                seed:
                  type: integer
                  description: >-
                    Optional random seed for reproducible attempts on model
                    versions that support seeding. Use `-1` or omit the field
                    for a random seed.
                  minimum: -1
                  maximum: 2147483647
                  default: -1
                guidance_scale:
                  type: number
                  description: >-
                    Optional prompt-adherence control for model versions that
                    support it. Higher values can follow the prompt more closely
                    but may reduce naturalness.
                  minimum: 1
                  maximum: 10
                watermark:
                  type: boolean
                  description: >-
                    When `true`, requests a visible AI-generated watermark on
                    the output image. Set `false` when your workflow handles
                    disclosure separately.
                  default: false
              default:
                model: doubao-seededit-3-0-i2i-250628
                image: data:image/png;base64,YOUR_BASE64_IMAGE
                prompt: >-
                  Change the red square into a blue square and keep the
                  background unchanged.
                response_format: url
                size: 2K
                watermark: false
            examples:
              Image data URI (JSON):
                summary: Edit an image supplied as a data URI
                value:
                  model: doubao-seededit-3-0-i2i-250628
                  image: data:image/png;base64,YOUR_BASE64_IMAGE
                  prompt: >-
                    Change the red square into a blue square and keep the
                    background unchanged.
                  response_format: url
                  size: 2K
                  watermark: false
              Masked edit (JSON):
                summary: Edit an image with a mask supplied as a data URI
                value:
                  model: doubao-seededit-3-0-i2i-250628
                  image: data:image/png;base64,YOUR_BASE64_IMAGE
                  mask: data:image/png;base64,YOUR_BASE64_MASK
                  prompt: >-
                    Change only the masked red square into a blue square and
                    keep the background unchanged.
                  response_format: url
                  size: 2K
                  watermark: false
          multipart/form-data:
            schema:
              type: object
              description: Parameters for SeedEdit image editing with uploaded image files.
              required:
                - model
                - image
                - prompt
              properties:
                model:
                  type: string
                  description: >-
                    SeedEdit model ID to use. Query `/v1/models` or open the
                    [Models page](/overview/models) for available image editing
                    model IDs.
                  default: doubao-seededit-3-0-i2i-250628
                image:
                  type: string
                  format: binary
                  description: >-
                    Source image file to edit. Use JPEG or PNG input and keep
                    the file within the route size limit.
                mask:
                  type: string
                  format: binary
                  description: >-
                    Optional mask image file. Use a high-contrast PNG mask to
                    mark the region that should receive the edit.
                prompt:
                  type: string
                  description: >-
                    Instruction describing the desired edit, such as `Change the
                    red square into a blue square and keep the background
                    unchanged`.
                  default: >-
                    Change the red square into a blue square and keep the
                    background unchanged.
                response_format:
                  type: string
                  description: >-
                    Response image format. Use `url` for a temporary signed
                    image URL, or `b64_json` when you need base64 image data in
                    the response.
                  default: url
                  enum:
                    - url
                    - b64_json
                size:
                  type: string
                  description: >-
                    Output resolution. Use a tier such as `1K`, `2K`, or `4K`,
                    or a model-supported `WIDTHxHEIGHT` value such as
                    `2048x2048`. Omit the field to use the route default.
                  default: 2K
                seed:
                  type: integer
                  description: >-
                    Optional random seed for reproducible attempts on model
                    versions that support seeding. Use `-1` or omit the field
                    for a random seed.
                  minimum: -1
                  maximum: 2147483647
                  default: -1
                guidance_scale:
                  type: number
                  description: >-
                    Optional prompt-adherence control for model versions that
                    support it. Higher values can follow the prompt more closely
                    but may reduce naturalness.
                  minimum: 1
                  maximum: 10
                watermark:
                  type: boolean
                  description: >-
                    When `true`, requests a visible AI-generated watermark on
                    the output image. Set `false` when your workflow handles
                    disclosure separately.
                  default: false
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                required:
                  - created
                  - data
                properties:
                  created:
                    type: integer
                    description: >-
                      Unix timestamp in seconds when the image response was
                      created.
                  data:
                    type: array
                    description: Edited image results.
                    items:
                      type: object
                      properties:
                        url:
                          type: string
                          description: >-
                            Temporary signed URL for the edited image. Save or
                            download the image before the URL expires.
                        b64_json:
                          type: string
                          description: >-
                            Base64-encoded image data when `response_format` is
                            `b64_json`.
                        size:
                          type: string
                          description: >-
                            Pixel dimensions of the edited image when returned
                            by the model, such as `2048x2048`.
                  usage:
                    type: object
                    description: >-
                      Usage information for the request. Fields vary by model
                      and route.
                    properties:
                      output_tokens:
                        type: integer
                        description: >-
                          Image output tokens charged for the edited image data,
                          when reported.
                      total_tokens:
                        type: integer
                        description: Total tokens reported for the request.
                      prompt_tokens:
                        type: integer
                        description: Prompt tokens reported by the route, when available.
                      completion_tokens:
                        type: integer
                        description: >-
                          Completion tokens reported by the route, when
                          available.
      x-codeSamples:
        - lang: Shell
          label: Image data URI (JSON)
          source: |
            curl -s https://api.cometapi.com/v1/images/edits \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              -H "Content-Type: application/json" \
              -d '{
              "model": "doubao-seededit-3-0-i2i-250628",
              "image": "data:image/png;base64,YOUR_BASE64_IMAGE",
              "prompt": "Change the red square into a blue square and keep the background unchanged.",
              "response_format": "url",
              "size": "2K",
              "watermark": false
            }' | jq -r '.data[]? | .url // .b64_json'
        - lang: Python
          label: Image data URI (JSON)
          source: |
            import os
            import requests

            response = requests.post(
                "https://api.cometapi.com/v1/images/edits",
                headers={
                    "Authorization": "Bearer " + os.environ["COMETAPI_KEY"],
                    "Content-Type": "application/json",
                },
                json={"model": "doubao-seededit-3-0-i2i-250628", "image": "data:image/png;base64,YOUR_BASE64_IMAGE", "prompt": "Change the red square into a blue square and keep the background unchanged.", "response_format": "url", "size": "2K", "watermark": False},
                timeout=180,
            )
            response.raise_for_status()
            result = response.json()

            for image in result.get("data", []):
                print(image.get("url") or image.get("b64_json"))
        - lang: JavaScript
          label: Image data URI (JSON)
          source: >
            const response = await
            fetch("https://api.cometapi.com/v1/images/edits", {
              method: "POST",
              headers: {
                Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
                "Content-Type": "application/json",
              },
              body: JSON.stringify({
              "model": "doubao-seededit-3-0-i2i-250628",
              "image": "data:image/png;base64,YOUR_BASE64_IMAGE",
              "prompt": "Change the red square into a blue square and keep the background unchanged.",
              "response_format": "url",
              "size": "2K",
              "watermark": false
            }),

            });


            if (!response.ok) {
              throw new Error(await response.text());
            }


            const result = await response.json();

            for (const image of result.data ?? []) {
              console.log(image.url ?? image.b64_json);
            }
        - lang: Shell
          label: Masked edit (JSON)
          source: |
            curl -s https://api.cometapi.com/v1/images/edits \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              -H "Content-Type: application/json" \
              -d '{
              "model": "doubao-seededit-3-0-i2i-250628",
              "image": "data:image/png;base64,YOUR_BASE64_IMAGE",
              "mask": "data:image/png;base64,YOUR_BASE64_MASK",
              "prompt": "Change only the masked red square into a blue square and keep the background unchanged.",
              "response_format": "url",
              "size": "2K",
              "watermark": false
            }' | jq -r '.data[]? | .url // .b64_json'
        - lang: Python
          label: Masked edit (JSON)
          source: |
            import os
            import requests

            response = requests.post(
                "https://api.cometapi.com/v1/images/edits",
                headers={
                    "Authorization": "Bearer " + os.environ["COMETAPI_KEY"],
                    "Content-Type": "application/json",
                },
                json={"model": "doubao-seededit-3-0-i2i-250628", "image": "data:image/png;base64,YOUR_BASE64_IMAGE", "mask": "data:image/png;base64,YOUR_BASE64_MASK", "prompt": "Change only the masked red square into a blue square and keep the background unchanged.", "response_format": "url", "size": "2K", "watermark": False},
                timeout=180,
            )
            response.raise_for_status()
            result = response.json()

            for image in result.get("data", []):
                print(image.get("url") or image.get("b64_json"))
        - lang: JavaScript
          label: Masked edit (JSON)
          source: >
            const response = await
            fetch("https://api.cometapi.com/v1/images/edits", {
              method: "POST",
              headers: {
                Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
                "Content-Type": "application/json",
              },
              body: JSON.stringify({
              "model": "doubao-seededit-3-0-i2i-250628",
              "image": "data:image/png;base64,YOUR_BASE64_IMAGE",
              "mask": "data:image/png;base64,YOUR_BASE64_MASK",
              "prompt": "Change only the masked red square into a blue square and keep the background unchanged.",
              "response_format": "url",
              "size": "2K",
              "watermark": false
            }),

            });


            if (!response.ok) {
              throw new Error(await response.text());
            }


            const result = await response.json();

            for (const image of result.data ?? []) {
              console.log(image.url ?? image.b64_json);
            }
        - lang: Shell
          label: Upload file
          source: |
            curl -s https://api.cometapi.com/v1/images/edits \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              -F model="doubao-seededit-3-0-i2i-250628" \
              -F prompt="Change the red square into a blue square and keep the background unchanged." \
              -F response_format="url" \
              -F size="2K" \
              -F watermark="false" \
              -F image=@source.png | jq -r '.data[]? | .url // .b64_json'
        - lang: Python
          label: Upload file
          source: |
            import os
            import requests

            try:
                image_file = open("source.png", "rb")
                response = requests.post(
                    "https://api.cometapi.com/v1/images/edits",
                    headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                    data={"model": "doubao-seededit-3-0-i2i-250628", "prompt": "Change the red square into a blue square and keep the background unchanged.", "response_format": "url", "size": "2K", "watermark": "false"},
                    files={
                        "image": image_file
                    },
                    timeout=180,
                )
                response.raise_for_status()
                result = response.json()
                print(result["data"][0].get("url") or result["data"][0].get("b64_json"))
            finally:
                image_file.close()
        - lang: JavaScript
          label: Upload file
          source: >
            import { readFile } from "node:fs/promises";


            const form = new FormData();

            form.append("model", "doubao-seededit-3-0-i2i-250628");

            form.append("prompt", "Change the red square into a blue square and
            keep the background unchanged.");

            form.append("response_format", "url");

            form.append("size", "2K");

            form.append("watermark", "false");

            form.append("image", new Blob([await readFile("source.png")], {
            type: "image/png" }), "source.png");


            const response = await
            fetch("https://api.cometapi.com/v1/images/edits", {
              method: "POST",
              headers: { Authorization: `Bearer ${process.env.COMETAPI_KEY}` },
              body: form,
            });


            if (!response.ok) {
              throw new Error(await response.text());
            }


            const result = await response.json();

            console.log(result.data[0].url ?? result.data[0].b64_json);
        - lang: Shell
          label: Masked upload
          source: |
            curl -s https://api.cometapi.com/v1/images/edits \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              -F model="doubao-seededit-3-0-i2i-250628" \
              -F prompt="Change only the masked red square into a blue square and keep the background unchanged." \
              -F response_format="url" \
              -F size="2K" \
              -F watermark="false" \
              -F image=@source.png \
              -F mask=@mask.png | jq -r '.data[]? | .url // .b64_json'
        - lang: Python
          label: Masked upload
          source: |
            import os
            import requests

            try:
                image_file = open("source.png", "rb")
                mask_file = open("mask.png", "rb")
                response = requests.post(
                    "https://api.cometapi.com/v1/images/edits",
                    headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                    data={"model": "doubao-seededit-3-0-i2i-250628", "prompt": "Change only the masked red square into a blue square and keep the background unchanged.", "response_format": "url", "size": "2K", "watermark": "false"},
                    files={
                        "image": image_file,
                        "mask": mask_file
                    },
                    timeout=180,
                )
                response.raise_for_status()
                result = response.json()
                print(result["data"][0].get("url") or result["data"][0].get("b64_json"))
            finally:
                image_file.close()
                mask_file.close()
        - lang: JavaScript
          label: Masked upload
          source: >
            import { readFile } from "node:fs/promises";


            const form = new FormData();

            form.append("model", "doubao-seededit-3-0-i2i-250628");

            form.append("prompt", "Change only the masked red square into a blue
            square and keep the background unchanged.");

            form.append("response_format", "url");

            form.append("size", "2K");

            form.append("watermark", "false");

            form.append("image", new Blob([await readFile("source.png")], {
            type: "image/png" }), "source.png");

            form.append("mask", new Blob([await readFile("mask.png")], { type:
            "image/png" }), "mask.png");


            const response = await
            fetch("https://api.cometapi.com/v1/images/edits", {
              method: "POST",
              headers: { Authorization: `Bearer ${process.env.COMETAPI_KEY}` },
              body: form,
            });


            if (!response.ok) {
              throw new Error(await response.text());
            }


            const result = await response.json();

            console.log(result.data[0].url ?? result.data[0].b64_json);
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Bearer token authentication. Use your CometAPI key.

````