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

# Edit Image

> Edit or recompose one or more input images from a text prompt using
OpenAI's GPT Image 2 model.

**Key Features:**
- Accepts 1-16 input images, used together as the visual context
- Restyle a single image, or compose a new one from several
- Same output controls as text-to-image (resolution, aspect ratio, format, compression, quality)

**Best for:**
- Product and scene variations from an existing shot
- Combining a subject, a background and a style reference in one call
- Adding or correcting text on an existing image

**Output:** one edited image per `num_images` (up to 10), delivered as
CDN URLs in the task's `generated` array. The input images are never
modified.

**Credits:** editing sends your images to the model and their input
tokens dominate the cost, so it is priced differently from generation:
flat units per output image by `quality` (`low` x1, `medium` x4,
`high` x6), with `resolution` not affecting the price.

The request is processed asynchronously: the endpoint returns a task id
immediately. Retrieve the result by polling the task endpoint or by
providing an optional `webhook_url`.




## OpenAPI

````yaml POST /v1/ai/text-to-image/gpt-image-2-edit
openapi: 3.0.0
info:
  description: >-
    The Magnific API is your gateway to a vast collection of high-quality
    digital resources for your applications and projects. As a leading platform,
    it offers a wide range of graphics, including vectors, photos,
    illustrations, icons, PSD templates, and more, all curated by talented
    designers from around the world.
  title: Magnific API
  version: 1.0.0
servers:
  - description: B2B API Production V1
    url: https://api.magnific.com
security:
  - magnificApiKey: []
paths:
  /v1/ai/text-to-image/gpt-image-2-edit:
    post:
      tags:
        - text-to-image
      summary: Edit images from text - GPT Image 2
      description: >
        Edit or recompose one or more input images from a text prompt using

        OpenAI's GPT Image 2 model.


        **Key Features:**

        - Accepts 1-16 input images, used together as the visual context

        - Restyle a single image, or compose a new one from several

        - Same output controls as text-to-image (resolution, aspect ratio,
        format, compression, quality)


        **Best for:**

        - Product and scene variations from an existing shot

        - Combining a subject, a background and a style reference in one call

        - Adding or correcting text on an existing image


        **Output:** one edited image per `num_images` (up to 10), delivered as

        CDN URLs in the task's `generated` array. The input images are never

        modified.


        **Credits:** editing sends your images to the model and their input

        tokens dominate the cost, so it is priced differently from generation:

        flat units per output image by `quality` (`low` x1, `medium` x4,

        `high` x6), with `resolution` not affecting the price.


        The request is processed asynchronously: the endpoint returns a task id

        immediately. Retrieve the result by polling the task endpoint or by

        providing an optional `webhook_url`.
      operationId: edit_image_from_text_gpt_image_2
      requestBody:
        content:
          application/json:
            examples:
              required-params:
                $ref: '#/components/examples/request-gpt-image-2-edit-required-params'
              all-params:
                $ref: '#/components/examples/request-gpt-image-2-edit-all-params'
            schema:
              $ref: '#/components/schemas/ttigi2-edit-request-content'
        required: true
      responses:
        '200':
          content:
            application/json:
              examples:
                success - in progress task:
                  $ref: '#/components/examples/200-task-in-progress'
              schema:
                $ref: >-
                  #/components/schemas/get_style_transfer_task_status_200_response
          description: >-
            OK - The request has succeeded and the GPT Image 2 Edit process has
            started.
        '400':
          $ref: '#/components/responses/400-bad-request'
        '401':
          $ref: '#/components/responses/401-unauthorized'
        '500':
          $ref: '#/components/responses/500-internal-server-error'
        '503':
          $ref: '#/components/responses/503-service-unavailable'
components:
  examples:
    request-gpt-image-2-edit-required-params:
      description: A prompt and at least one reference image.
      summary: Minimum request
      value:
        prompt: Put the product on a marble surface, keep the label unchanged
        reference_images:
          - https://example.com/product.jpg
    request-gpt-image-2-edit-all-params:
      description: >
        Composes one image from three references. Editing is billed as flat
        units of

        the low tier by quality (low x1, medium x4, high x6) times num_images;

        resolution does not change the price of an edit.
      summary: Every parameter
      value:
        prompt: >-
          Place the subject from Image0 on the background of Image1, in the
          style of Image2
        reference_images:
          - https://example.com/subject.jpg
          - https://example.com/background.jpg
          - upl_img_0123456789abcdef
        num_images: 2
        resolution: 1k
        aspect_ratio: square_1_1
        quality: high
        output_format: png
        background: auto
        moderation: auto
        webhook_url: https://www.example.com/webhook
    200-task-in-progress:
      summary: Success - Task in progress
      value:
        data:
          generated: []
          task_id: 046b6c7f-0b8a-43b9-b35d-6489e6daee91
          status: IN_PROGRESS
  schemas:
    ttigi2-edit-request-content:
      properties:
        prompt:
          description: >
            Text instruction describing the edit to apply to the reference
            images.


            **Tips:**

            - Say what should change, not what the image already contains

            - Several references are used together as one visual context

            - Text inside the image can be corrected or replaced verbatim


            **Examples:**

            - Simple: "Put the product on a marble surface"

            - Detailed: "Replace the background with a sunlit studio, keep the
            product and its shadow, change the label text to ORGANIC"
          example: Put the product on a marble surface
          maxLength: 32000
          minLength: 1
          type: string
        reference_images:
          description: >
            The images to edit, in order. GPT Image 2 uses them together as the

            visual context for the prompt: it can restyle one image, or compose
            a

            new image from several.


            Each image may be up to 20 MiB, and one request may carry up to

            64 MiB of images in total.
          items:
            description: >
              Image URL (must be publicly reachable over HTTPS), a
              base64-encoded

              image, or an upload id returned by the uploads API.

              Supported formats: jpg, jpeg, png, webp.
            example: https://example.com/product.jpg
            type: string
          maxItems: 16
          minItems: 1
          type: array
        webhook_url:
          description: >
            Optional callback URL that will receive asynchronous notifications
            whenever the task changes status. The payload sent to this URL is
            the same as the corresponding GET endpoint response, but without the
            data field.
          example: https://www.example.com/webhook
          format: uri
          type: string
        num_images:
          default: 1
          description: |
            How many images to generate for this prompt. **Each image is billed
            separately.**
          example: 1
          maximum: 10
          minimum: 1
          type: integer
        resolution:
          default: 1k
          description: >
            Resolution tier of the generated image. Combined with `aspect_ratio`
            it

            selects the exact pixel size.


            **Credits:** the tier multiplies the price set by `quality` — `1k`
            x1,

            `2k` x2, `4k` x3. On the edit endpoint it does not affect the price.
          enum:
            - 1k
            - 2k
            - 4k
          example: 1k
          type: string
        aspect_ratio:
          default: square_1_1
          description: >
            Image size with the aspect ratio. The aspect ratio is the
            proportional

            relationship between an image's width and height, expressed as

            *_width_height (e.g., square_1_1, widescreen_16_9). It is calculated
            by

            dividing the width by the height.

            If not present, the default is `square_1_1`.
          enum:
            - square_1_1
            - classic_4_3
            - traditional_3_4
            - widescreen_16_9
            - social_story_9_16
            - film_horizontal_21_9
            - standard_3_2
            - portrait_2_3
            - horizontal_2_1
            - banner_3_1
          example: square_1_1
          type: string
        quality:
          default: high
          description: >
            Render quality tier. Higher tiers spend more provider compute and
            cost

            more credits; lower tiers are faster and cheaper.

            - `low`: fastest and cheapest, for drafts and iteration

            - `medium`: balanced

            - `high`: maximum detail and prompt adherence (default)
          enum:
            - low
            - medium
            - high
          example: high
          type: string
        output_format:
          default: png
          description: >
            The file format of the generated image.

            - `png`: lossless, supports transparency. Best for logos, text and
            sharp edges

            - `jpeg`: compressed, no transparency. Smallest files for
            photographic content

            - `webp`: compressed, supports transparency


            `output_compression` only applies to `jpeg` and `webp`.
          enum:
            - png
            - jpeg
            - webp
          example: png
          type: string
        background:
          description: >
            How the image background is produced.

            - `opaque`: always render a filled background

            - `auto`: let the model decide, which may return a transparent
            background


            Transparency is only preserved by formats that support an alpha
            channel

            (`png`, `webp`). When omitted, the provider default applies.
          enum:
            - opaque
            - auto
          example: auto
          type: string
        output_compression:
          description: |
            Compression level for the generated image, where 100 is the least
            compressed. Only applies when `output_format` is `jpeg` or `webp`;
            ignored for `png`.
          example: 80
          maximum: 100
          minimum: 0
          type: integer
        moderation:
          default: auto
          description: |
            Strictness of the model provider's own content filter.
            - `auto`: the provider's standard filtering (default)
            - `low`: less restrictive filtering

            This is the model provider's filter and is applied in addition to
            Freepik's platform moderation, which cannot be disabled.
          enum:
            - auto
            - low
          example: auto
          type: string
      required:
        - prompt
        - reference_images
      type: object
    get_style_transfer_task_status_200_response:
      example:
        data:
          generated:
            - https://openapi-generator.tech
            - https://openapi-generator.tech
          task_id: 046b6c7f-0b8a-43b9-b35d-6489e6daee91
          status: CREATED
      properties:
        data:
          $ref: '#/components/schemas/task-detail'
      required:
        - data
      type: object
    task-detail:
      allOf:
        - $ref: '#/components/schemas/task'
        - properties:
            generated:
              items:
                description: URL of the generated image
                format: uri
                type: string
              type: array
          required:
            - generated
          type: object
      example:
        generated:
          - https://openapi-generator.tech
          - https://openapi-generator.tech
        task_id: 046b6c7f-0b8a-43b9-b35d-6489e6daee91
        status: CREATED
    inline_object:
      example:
        message: message
      properties:
        message:
          type: string
      type: object
    inline_object_1:
      properties:
        problem:
          $ref: '#/components/schemas/inline_object_1_problem'
      type: object
    inline_object_2:
      example:
        message: Internal Server Error
      properties:
        message:
          example: Internal Server Error
          type: string
      type: object
    inline_object_3:
      example:
        message: Service Unavailable. Please try again later.
      properties:
        message:
          example: Service Unavailable. Please try again later.
          type: string
      type: object
    task:
      example:
        task_id: 046b6c7f-0b8a-43b9-b35d-6489e6daee91
        status: CREATED
      properties:
        task_id:
          description: Task identifier
          format: uuid
          type: string
        status:
          description: Task status
          enum:
            - CREATED
            - IN_PROGRESS
            - COMPLETED
            - FAILED
          type: string
      required:
        - status
        - task_id
      type: object
    inline_object_1_problem:
      properties:
        message:
          example: Validation error
          type: string
        invalid_params:
          items:
            $ref: '#/components/schemas/inline_object_1_problem_invalid_params_inner'
          type: array
      required:
        - invalid_params
        - message
      type: object
    inline_object_1_problem_invalid_params_inner:
      properties:
        name:
          description: Name of the invalid parameter.
          example: page
          type: string
        field:
          description: Field of the invalid parameter. Mirrors `name`.
          example: page
          type: string
        reason:
          example: Parameter 'page' must be greater than 0
          type: string
      required:
        - field
        - name
        - reason
      type: object
  responses:
    400-bad-request:
      content:
        application/json:
          examples:
            invalid_page:
              summary: Parameter 'page' is not valid
              value:
                message: Parameter 'page' must be greater than 0
            invalid_query:
              summary: Parameter 'query' is not valid
              value:
                message: Parameter 'query' must not be empty
            invalid_filter:
              summary: Parameter 'filter' is not valid
              value:
                message: Parameter 'filter' is not valid
            generic_bad_request:
              summary: Bad Request
              value:
                message: Parameter ':attribute' is not valid
          schema:
            $ref: '#/components/schemas/inline_object'
        application/problem+json:
          examples:
            invalid_page:
              summary: Parameter 'page' is not valid
              value:
                message: Validation error
                invalid_params:
                  - field: page
                    reason: Parameter 'page' must be greater than 0
                  - field: per_page
                    reason: Parameter 'per_page' must be greater than 0
          schema:
            $ref: '#/components/schemas/inline_object_1'
      description: >-
        Bad Request - The server could not understand the request due to invalid
        syntax.
    401-unauthorized:
      content:
        application/json:
          examples:
            invalid_api_key:
              summary: API key is not valid
              value:
                message: Invalid API key
            missing_api_key:
              summary: API key is not provided
              value:
                message: Missing API key
          schema:
            $ref: '#/components/schemas/inline_object'
      description: >-
        Unauthorized - The client must authenticate itself to get the requested
        response.
    500-internal-server-error:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/inline_object_2'
      description: >-
        Internal Server Error - The server has encountered a situation it
        doesn't know how to handle.
    503-service-unavailable:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/inline_object_3'
      description: Service Unavailable
  securitySchemes:
    magnificApiKey:
      description: >
        Your Magnific API key. Required for authentication. [Learn how to obtain
        an API key](https://docs.magnific.com/quickstart)
      in: header
      name: x-magnific-api-key
      type: apiKey

````