---
title: "Create an inpaint, outpaint or redraw task"
description: "Edits an existing image:"
canonical: "https://platform.pixai.art/en/docs/api-v2/image/createInpaint"
last-updated: "2026-11-02"
---

# Create an inpaint, outpaint or redraw task

Edits an existing image:



* **Inpaint** (`fillType: inpaint`): redraws the masked area.
* **Outpaint** (`fillType: outpaint`): extends the image beyond its edges. Place the original on a larger white canvas and send that as `baseImageMediaId`; the mask marks the new area.
* **Redraw** (`fillType: inpaint`, no mask): redraws the whole image, keeping it closer to the original as `strength` goes down.

A masked edit takes two extra images, always sent together:

* `maskMediaId`: same size as the base image, white where to redraw and black where to keep.
* `maskedImageMediaId`: the base image with the white area of the mask painted gray (`#808080`).

The output has the size of the masked image when a mask is sent, otherwise of the base image. Images are media IDs; see `POST /v2/media/image/upload-url`.

Use `modelPreset: "v1"`. `GET /v2/gen-task/inpaint/constraints` lists the size limits and `sdeditPreset` names of a preset. Credits are charged when the task is created; the result is `outputs.mediaIds[0]` of `GET /v2/task/{id}`.

## POST https://api.pixai.art/v2/gen-task/inpaint

Authentication: send your API key as `Authorization: Bearer <API key>`.

Machine-readable OpenAPI spec: https://platform.pixai.art/openapi-spec.v2.yaml

### Request body (`application/json`)

- `modelPreset` (string, required)
  The inpaint model. Use `v1`.
  Example: `"v1"`.
- `fillType` (string, required)
  Allowed values: `inpaint`, `outpaint`.
- `baseImageMediaId` (string, required)
  Image media ID of the image to edit.
- `maskMediaId` (string, optional)
  Image media ID of the mask, white where to redraw and black where to keep. Send it with `maskedImageMediaId`, or omit both to redraw the whole image.
- `maskedImageMediaId` (string, optional)
  Image media ID of the base image with the mask's white area painted `#808080`. Send it with `maskMediaId`.
- `prompt` (string, optional)
  What to draw in the edited area.
  Default: `""`.
  Length: 0 to 10000 characters.
- `strength` (number, optional)
  How far the result may depart from the original. Lower keeps it closer.
  Range: 0 to 1.
- `seed` (integer, optional)
  Random seed. Omit for a random one.
- `promptHelper` (string, optional)
  How much PixAI may expand the prompt.
  Allowed values: `enable`, `disable`, `low`, `medium`.
  Default: `"enable"`.
- `sdeditPreset` (string, optional)
  A redraw preset name from `GET /v2/gen-task/inpaint/constraints`. Sending one to a preset without any answers `SDEDIT_NOT_AVAILABLE`.
  Length: 1 to 64 characters.
- `sdedit` (object, optional)
  Fine-tuning for redraws. With `sdeditPreset`, only `colorCorrection` is taken from here.
- `sdedit.spectralScale` (number, optional)
  Range: 0 to 1.
- `sdedit.hfsBlurSigma` (number, optional)
  Range: 0 to 32.
- `sdedit.hfsEnd` (number, optional)
  Range: 0 to 1.
- `sdedit.colorCorrection` (boolean, optional)
  Match the colors of the original.

Example:

```json
{
  "modelPreset": "v1",
  "fillType": "inpaint",
  "baseImageMediaId": "1943547603237249965",
  "maskMediaId": "1943547603237249966",
  "prompt": "red scarf"
}
```

### Example (cURL)

```bash
curl -X POST https://api.pixai.art/v2/gen-task/inpaint \
  -H "Authorization: Bearer $PIXAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "modelPreset": "v1",
    "fillType": "inpaint",
    "baseImageMediaId": "1943547603237249965",
    "maskMediaId": "1943547603237249966",
    "prompt": "red scarf"
  }'
```

### Responses

- `201`
  The task was created. Poll `GET /v2/task/{id}` with its `id`.
  Body fields:
  - `id` (string, required)
    The unique identifier for the task.
  - `status` (string, required)
    The current status of the task.
    Allowed values: `waiting`, `running`, `completed`, `cancelled`, `failed`.
  - `createdAt` (string, required)
    The time the task was created.
  - `updatedAt` (string, required)
    The time the task was last updated.
  - `startedAt` (string, optional)
    The time the task started running.
  - `endAt` (string, optional)
    The time the task finished.
  - `taskKind` (string, optional)
    What the task makes: `t2i` or `i2i` for images, `inpaint` for `POST /v2/gen-task/inpaint`, `i2v-inhouse` for `POST /v2/frame-video/create`, `reference-video` for `POST /v2/reference-video/create`.
  - `paidQuota` (integer, optional)
    Credits charged for the task.
  - `taskStatusMsgI18n` (object, optional)
    Why a `failed` task failed.
  - `taskStatusMsgI18n.key` (string, optional)
    A stable message key.
  - `taskStatusMsgI18n.defaultMessage` (string, optional)
    The message in English.
  - `outputs` (object, optional)
    The outputs produced by the task.
  - `outputs.videoMediaId` (string, optional)
    For video tasks, the media ID of the video. Resolve it with `GET /v2/media/batch?ids=<videoMediaId>` and download `fileUrl`. `mediaIds` then holds only the poster image.
  - `outputs.seed` (string, optional)
    The seed used, as a decimal string.
  - `outputs.mediaIds` (string[], optional)
    Media IDs of the generated images. Use these IDs to fetch detailed information about each generated image.

    Generated images are not permanently retained — retrieve them as soon as possible.
  - `outputs.mediaUrls` ((string | null)[], optional)
    Public URLs of the generated images.

    Generated images are not permanently retained — retrieve them as soon as possible. If an image is unavailable, its entry may be `null`.
- `400`
  - `INVALID_MODEL_PRESET`: unknown `modelPreset`.
  - `INVALID_MEDIA`: an image media ID does not exist or is not an image.
  - `INVALID_SDEDIT_PRESET`: unknown `sdeditPreset`.
  - `SDEDIT_NOT_AVAILABLE`: this `modelPreset` takes no `sdeditPreset` or `sdedit`.
  - `BAD_REQUEST` with `data.issues`: the body failed validation.
- `401`
  `UNAUTHORIZED`: no API key was sent. An invalid, revoked or expired key answers `{"message": "invalid token", "code": 40100001}` instead, with a numeric `code`.
- `403`
  The account cannot run this task right now. `code` says why:

  - `INSUFFICIENT_BALANCE`: not enough credits for the task.
  - `WAITING_NUM_EXCEEDED`: too many of your tasks are still `waiting` (`data.currentWaitingTasks`). Wait for some to start before submitting more.
  - `REQUIRE_MEMBERSHIP`: the feature needs a PixAI membership (image-to-video).
  - `NSFW_PROMPTS_DETECTED`: the prompt was refused because the account is in safe mode.
- `500`
  `CREATION_FAILED`: the task could not be created. Retry with exponential backoff.
