# Stable Diffusion with LoRAs · Inpaint API

> 選択したStable DiffusionベースモデルとLoRAsを使い、白黒マスクでガイドするインペイント

`model_name` で指定した Stable Diffusion モデルを使い、`image_url` と白黒の `mask_url` で画像の一部を編集します。`noise_strength` は 0 から 1 の範囲です。マージ済み LoRA、埋め込み、ControlNet、IP adapter、複数のスケジューラーに対応し、ステップは 1 から 150 です。出力は png または jpeg です。

- Model id: `lora/inpaint`
- Made by: Open model
- Category: Image Editing
- Output: image
- Estimated price per run: $0.184 / image (cheapest run $0.184 (184 API credits))
- Run: `POST https://api.doitong.com/v1/run/lora/inpaint`
- Quote: `POST https://api.doitong.com/v1/quote/lora/inpaint`
- Docs page: https://doitong.com/ja/developers/models/lora/inpaint

## Pricing

Price: **$0.184 / image**. Estimated from the typical cost of one run, per output (`num_images`). The quote is exactly what the run charges.

The full example input below costs $0.184 = 184 API credits (1 image × 184 API credits).

Prices are the upstream price in USD, paid from the API balance in API credits (1000 API credits = 1 USD). `POST https://api.doitong.com/v1/quote/lora/inpaint` with the same JSON body returns the exact price for that input; the quote is exactly what a run charges. Invalid input is never charged and failed or canceled requests are refunded automatically.

## Input parameters

Send either the canonical name or the native field name (not both). Canonical names are the same across models.

| Parameter | Canonical name | Type | Required | Default | Allowed values / range | Description |
|---|---|---|---|---|---|---|
| `model_name` |  | string | yes |  |  | 画像生成に使用するベースモデル。URLまたはHuggingFace IDで指定します。 |
| `unet_name` |  | string \| null | no |  |  | 画像生成に使用するカスタムU-Netの選択。HuggingFace IDまたはURLを指定します。 |
| `variant` |  | string \| null | no |  |  | HuggingFaceモデルバリアントの選択。例として'fp16'があります。 |
| `prompt` |  | string | yes |  |  | 生成したい画像をできるだけ詳しく説明してください。最良の結果を得るには詳細な記述を使用します。 |
| `negative_prompt` |  | string | no | `` |  | 望ましくない画像の詳細を指定するネガティブプロンプト。色、オブジェクト、景色、細部、口ひげ、ぼけ、低解像度などの特徴や品質を除外できます。 |
| `prompt_weighting` |  | boolean | no | `false` |  | プロンプトの重み付け切り替え: true にすると、埋め込みの平均化によって77トークン制限を解除し、重み付け構文を有効にします。 |
| `image_url` | `image` | string (image URL) \| null | no |  |  | 画像から画像への生成またはインペインティングに使用するソース画像URL。 |
| `mask_url` | `mask` | string (image URL) \| null | no |  |  | 白黒画像を指すインペインティングマスクURL。 |
| `noise_strength` |  | number | no | `0.5` | ≤ 1, > 0 | 追加する画像ノイズを制御します。1.0は完全なノイズ、0に近い値は最小限のノイズを意味します。image_url が指定されている場合のみ適用されます。 |
| `loras` |  | array of object {path, scale} | no | `[]` |  | 組み合わせた効果で生成画像を作るLoRA。指定数に制限はありません。 |
| `loras[].path` |  | string | yes |  |  | URLまたはパスで指定するLoRAウェイトの場所。 |
| `loras[].scale` |  | number | no | `1` | 0 – 4 | ベースモデルに統合する前にLoRAウェイトへ適用する倍率。 |
| `embeddings` |  | array of object {path, tokens} | no | `[]` |  | 画像生成中に適用され、プロンプトのトークンを埋め込みの重みに対応付ける埋め込み。現在は1つのみサポートされています。 |
| `embeddings[].path` |  | string | yes |  |  | URLまたはファイルパスで指定する埋め込みウェイト。 |
| `embeddings[].tokens` |  | array of string \| null | no |  |  | プロンプトのトークンを埋め込みの重みに対応付けます。省略すると、埋め込みファイルの各ベクトルにつき1つのトークンが作成され、<s0>、<s1>、...という名前になります。プロンプトでは対応付けたトークンを使用してください。 |
| `controlnets` |  | array of object {path, config_url, variant, image_url, mask_url, conditioning_scale, start_percentage, end_percentage, ip_adapter_index} | no | `[]` |  | 生成中の指定したタイムステップで画像に適用するControl net。指定数に制限はありません。 |
| `controlnets[].path` |  | string | yes |  |  | ControlNetの重みの場所。URLまたはパスで指定します。 |
| `controlnets[].config_url` |  | string \| null | no |  |  | ControlNetのconfig.jsonファイルを指す任意のURL。 |
| `controlnets[].variant` |  | string \| null | no |  |  | Hugging Faceリポジトリキーで使用する任意のバリアント。 |
| `controlnets[].image_url` |  | string (image URL) | yes |  |  | ControlNetの入力として指定する画像URL。 |
| `controlnets[].mask_url` |  | string (image URL) \| null | no |  |  | ControlNetマスク。指定する場合は制御画像と同じサイズにする必要があり、幅と高さはそれぞれ32で割り切れる必要があります。 |
| `controlnets[].conditioning_scale` |  | number | no | `1` | 0 – 2 | ベースモデルにマージする前にControlNetの重みに適用するスケール。 |
| `controlnets[].start_percentage` |  | number | no | `0` | 0 – 1 | ControlNetが画像生成に影響し始める総タイムステップに対する割合。 |
| `controlnets[].end_percentage` |  | number | no | `1` | 0 – 1 | ControlNetが画像生成への影響を停止する総タイムステップに対する割合。 |
| `controlnets[].ip_adapter_index` |  | integer \| null | no |  |  | InstantID ControlNetのIP adapterをインデックスで選択します。他のControlNetでは不要です。 |
| `controlnet_guess_mode` |  | boolean | no | `false` |  | true の場合、ControlNetの適用を条件付き予測に限定します。 |
| `ip_adapter` |  | array of object {ip_adapter_image_url, ip_adapter_mask_url, path, model_subfolder, weight_name, insight_face_model_path, scale, scale_json, unconditional_noising_factor, image_projection_shortcut} | no | `[]` |  | 画像生成に使用するIP adapter。いずれかを指定する場合は image_encoder_path が必要です。 |
| `ip_adapter[].ip_adapter_image_url` |  | string (image URL) \| array of image URL | yes |  |  | IP adapterの入力として指定する画像URL。 |
| `ip_adapter[].ip_adapter_mask_url` |  | string (image URL) \| null | no |  |  | IP adapterマスク。指定する場合、アダプター画像と同じ寸法にする必要があります。 |
| `ip_adapter[].path` |  | string | yes |  |  | URLまたはパスで指定するIP adapterの重みの場所。 |
| `ip_adapter[].model_subfolder` |  | string \| null | no |  |  | モデルディレクトリ内のサブフォルダーとして指定するIP adapterの重みの場所。 |
| `ip_adapter[].weight_name` |  | string \| null | no |  |  | 重みのファイル名。 |
| `ip_adapter[].insight_face_model_path` |  | string \| null | no |  |  | URLまたはパスで指定するInsightFaceモデルの重みの場所。 |
| `ip_adapter[].scale` |  | number | no | `1` | ≥ 0 | IP adapterの重みに適用するスケーリング係数。ベースモデルに統合する前に適用されます。 |
| `ip_adapter[].scale_json` |  | object \| null | no |  |  | IP adapterの重みに適用するスケーリング係数。ベースモデルに統合する前に適用されます。 |
| `ip_adapter[].unconditional_noising_factor` |  | number | no | `0` | 0 – 1 | IP adapterの無条件ノイズ付加を制御する係数。 |
| `ip_adapter[].image_projection_shortcut` |  | boolean | no | `true` |  | 画像投影ショートカット設定。デフォルトは True です。FaceID plus V1モデルでは False、FaceID plus V2モデルでは True を使用してください。 |
| `image_encoder_path` |  | string \| null | no |  |  | HTTPS URLまたはHugging Face IDで指定する画像エンコーダー。互換性はIP-Adapterの重みによって決まり、SD1.5では image_encoder_subfolder='models/image_encoder'、h94/IP-Adapter SDXLでは h94/IP-Adapter と image_encoder_subfolder='sdxl_models/image_encoder' を使用します。ip_adapter に値が含まれる場合はエンコーダーが必要です。 |
| `image_encoder_subfolder` |  | string \| null | no |  |  | 画像エンコーダーの重みを格納する image_encoder_path 内のサブディレクトリ。 |
| `image_encoder_weight_name` |  | string \| null | no | `pytorch_model.bin` |  | 画像生成に使用する画像エンコーダーの重みを名前で選択します。 |
| `ic_light_model_url` |  | string \| null | no |  |  | 画像生成時に使用するIC LightモデルのURL。 |
| `ic_light_model_background_image_url` |  | string (image URL) \| null | no |  |  | IC Light画像生成用のモデル互換背景を画像URLで指定します。 |
| `ic_light_image_url` |  | string (image URL) \| null | no |  |  | IC Lightモデルで生成する際の入力画像URL。 |
| `seed` |  | integer \| null | no |  |  | Stable Diffusionで画像を再現するためのシード。モデルバージョン、プロンプト、シードを変更しなければ、毎回画像を完全に再現できます。 |
| `num_inference_steps` |  | integer | no | `30` | 1 – 150 | Stable Diffusion が実行する生成ステップ数を制御します。ステップを追加すると、より詳細な最終画像が得られる場合があります。 |
| `guidance_scale` |  | number | no | `7.5` | 0 – 20 | 画像選択におけるプロンプト準拠度。CFG（Classifier Free Guidance）として表します。 |
| `clip_skip` |  | integer | no | `0` | 0 – 2 | 画像生成の一部を省略して描画を高速化します。結果はわずかに異なる場合があります。 |
| `scheduler` |  | enum (string) \| null | no |  | `DPM++ 2M`, `DPM++ 2M Karras`, `DPM++ 2M SDE`, `DPM++ 2M SDE Karras`, `Euler`, `Euler A`, `Euler (trailing timesteps)`, `LCM`, `LCM (trailing timesteps)`, `DDIM`, `TCD` | 画像のデノイズに使用するスケジューラーまたはサンプラー。 |
| `timesteps` |  | object {method, array} | no | `{"array":[],"method":"default"}` |  | ノイズ除去タイムステップのスケジュール上書き。sigmasとは同時に指定できません。上書きしない場合（デフォルト）、スケジューラーは num_inference_steps からタイムステップを計算します。カスタムスケジュールを指定すると num_inference_steps は無効になります。上書きには、set_timesteps の timesteps 引数をサポートするスケジューラーが必要です。 |
| `timesteps.method` |  | enum (string) | no | `default` | `default`, `array` | タイムステップの決定方法を選択します: 'default'（デフォルト）ではスケジューラーが `num_inference_steps` を使用します。自分でスケジュールを指定するには 'array' を選び、スケジュールを `array` フィールドに設定します。 |
| `timesteps.array` |  | array of integer | no | `[]` |  | 選択した方式が 'custom' の場合に適用するタイムステップスケジュール。 |
| `sigmas` |  | object {method, array} | no | `{"array":[],"method":"default"}` |  | ノイズ除去sigmaスケジュールの上書き。timestepsとは同時に指定できません。上書きしない場合（デフォルト）、スケジューラーは num_inference_steps からsigmaを計算します。カスタムスケジュールを指定すると num_inference_steps は無効になります。上書きには、set_sigmas の sigmas 引数をサポートするスケジューラーが必要です。 |
| `sigmas.method` |  | enum (string) | no | `default` | `default`, `array` | sigmaの決定方法を選択します: 'default'（デフォルト）ではスケジューラー独自のsigma値を使用します。自分でsigmaスケジュールを指定するには 'custom' を選び、スケジュールを `array` フィールドに設定します。 |
| `sigmas.array` |  | array of number | no | `[]` |  | 選択した方式が 'custom' の場合に適用するsigmaスケジュール。 |
| `prediction_type` |  | enum (string) | no | `epsilon` | `v_prediction`, `epsilon` | 画像生成に使用する予測タイプを選択します。別の選択をしない場合は `epsilon` を使用します。 |
| `rescale_betas_snr_zero` |  | boolean | no | `false` |  | サンプラーで rescale_betas_snr_zero を有効にするかどうかを制御します。 |
| `image_format` |  | enum (string) | no | `png` | `jpeg`, `png` | 結果の画像のファイル形式。 |
| `num_images` | `num_outputs` | integer | no | `1` | 1 – 8 | 1回のリクエストで生成する画像数を設定します。バッチを大きくすると生成時間が長くなります。 |
| `enable_safety_checker` |  | boolean | no | `false` |  | 安全性チェッカーの有効化。true でチェックを有効にします。 |
| `tile_width` |  | integer | no | `4096` | 128 – 4,096 | 画像生成時の各タイルのサイズを設定します。 |
| `tile_height` |  | integer | no | `4096` | 128 – 4,096 | 画像生成時の各タイルのサイズを設定します。 |
| `tile_stride_width` |  | integer | no | `2048` | 64 – 2,048 | 画像生成時の連続するタイル位置間の間隔を設定します。 |
| `tile_stride_height` |  | integer | no | `2048` | 64 – 2,048 | 画像生成時の連続するタイル位置間の間隔を設定します。 |
| `eta` |  | number | no | `0` | 0 – 1 | 画像生成時に使用するEta設定。 |
| `debug_latents` |  | boolean | no | `false` |  | true の場合、デバッグ用に潜在変数を保存します。 |
| `debug_per_pass_latents` |  | boolean | no | `false` |  | true に設定するとパスごとのデバッグを有効にし、すべてのパスの潜在変数を保存します。 |

File parameters (`image`, `mask`, `ic_light_model_background_image_url`, `ic_light_image_url`) take a public `https://` URL, a `data:` URI up to 10 MB, or the `file_url` of an upload from `POST /files`.

## Example input

Required parameters only:

```json
{
  "model_name": "stabilityai/stable-diffusion-xl-base-1.0",
  "prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field"
}
```

A fuller example:

```json
{
  "model_name": "stabilityai/stable-diffusion-xl-base-1.0",
  "prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field"
}
```

## Run it

Set `DOITONG_API_KEY` to a key from https://doitong.com/developers/dashboard#keys. `?wait=20` returns the finished request in the same call when it is ready within 20 seconds; otherwise poll `GET /requests/{id}` (it also accepts `?wait=`), or pass `webhook_url`.

### curl

```bash
# Run the model; wait up to 20 s for the finished result in the same call
curl -X POST "https://api.doitong.com/v1/run/lora/inpaint?wait=20" \
  -H "Authorization: Bearer $DOITONG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model_name": "stabilityai/stable-diffusion-xl-base-1.0",
    "prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field"
  }'

# Still "queued" or "running"? Poll with the id from the response:
curl "https://api.doitong.com/v1/requests/REQUEST_ID?wait=20" \
  -H "Authorization: Bearer $DOITONG_API_KEY"
```

### JavaScript

```javascript
const API = "https://api.doitong.com/v1";
const headers = {
  "Authorization": "Bearer " + process.env.DOITONG_API_KEY,
  "Content-Type": "application/json",
};

// Run the model; wait up to 20 s for the finished result in the same call
let res = await fetch(API + "/run/lora/inpaint?wait=20", {
  method: "POST",
  headers,
  body: JSON.stringify({
    "model_name": "stabilityai/stable-diffusion-xl-base-1.0",
    "prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field"
  }),
});
let request = await res.json();
if (!res.ok) throw new Error(request.error.code + ": " + request.error.message);

// Not finished yet: long-poll until it is
while (request.status === "queued" || request.status === "running") {
  res = await fetch(API + "/requests/" + request.id + "?wait=20", { headers });
  request = await res.json();
}
if (request.status !== "succeeded") throw new Error(JSON.stringify(request.error));
console.log(request.outputs.map((o) => o.url), request.cost.credits + " API credits ($" + request.cost.usd + ")");
```

### Python

```python
import os
import requests

API = "https://api.doitong.com/v1"
headers = {"Authorization": "Bearer " + os.environ["DOITONG_API_KEY"]}

payload = {
    "model_name": "stabilityai/stable-diffusion-xl-base-1.0",
    "prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field",
}

# Run the model; wait up to 20 s for the finished result in the same call
r = requests.post(API + "/run/lora/inpaint", params={"wait": 20}, json=payload, headers=headers)
request = r.json()
if not r.ok:
    raise RuntimeError(request["error"]["code"] + ": " + request["error"]["message"])

# Not finished yet: long-poll until it is
while request["status"] in ("queued", "running"):
    request = requests.get(API + "/requests/" + request["id"], params={"wait": 20}, headers=headers).json()
if request["status"] != "succeeded":
    raise RuntimeError(request["error"])
print([o["url"] for o in request["outputs"]], request["cost"]["credits"], "API credits", "$" + request["cost"]["usd"])
```

### MCP

The MCP server at `https://api.doitong.com/v1/mcp` exposes the tools `search_models`, `get_model`, `quote`, `run`, `get_request`, `cancel_request`, `list_requests`, `create_upload` and `get_account`. A `run` call for this model:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "run",
    "arguments": {
      "model_id": "lora/inpaint",
      "input": {
        "model_name": "stabilityai/stable-diffusion-xl-base-1.0",
        "prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field"
      },
      "wait_seconds": 20
    }
  }
}
```

## Response

Every call returns a request object. `status` is one of `queued`, `running`, `succeeded`, `failed`, `canceled`. `outputs` lists the generated files with URLs on our storage (kept forever, or 7 days with `?storage=temporary`; `storage` says which); `output` is the model's own result object with the same URLs.

```json
{
  "id": "req_8k2m4q7x1z9c3v5b6n0p2r4t",
  "object": "request",
  "model": "lora/inpaint",
  "status": "succeeded",
  "created_at": "2026-10-20T12:00:00Z",
  "started_at": "2026-10-20T12:00:02Z",
  "completed_at": "2026-10-20T12:00:09Z",
  "queue_position": null,
  "cost": {
    "credits": 184,
    "usd": "0.184",
    "charged": 184,
    "refunded": 0
  },
  "input": {
    "model_name": "stabilityai/stable-diffusion-xl-base-1.0",
    "prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field"
  },
  "output": {
    "images": [
      {
        "url": "https://content.doitong.com/dev-api/2026/10/20/req_8k2m4q7x1z9c3v5b6n0p2r4t/0-output.jpeg",
        "content_type": "image/jpeg",
        "file_name": "0-output.jpeg",
        "file_size": 1843200,
        "width": 1024,
        "height": 768
      }
    ],
    "seed": 42,
    "has_nsfw_concepts": [
      false
    ],
    "debug_latents": {
      "url": "https://content.doitong.com/dev-api/2026/10/20/req_8k2m4q7x1z9c3v5b6n0p2r4t/0-output.jpeg",
      "content_type": "image/jpeg",
      "file_name": "0-output.jpeg",
      "file_size": 1843200
    },
    "debug_per_pass_latents": {
      "url": "https://content.doitong.com/dev-api/2026/10/20/req_8k2m4q7x1z9c3v5b6n0p2r4t/0-output.jpeg",
      "content_type": "image/jpeg",
      "file_name": "0-output.jpeg",
      "file_size": 1843200
    }
  },
  "outputs": [
    {
      "type": "image",
      "url": "https://content.doitong.com/dev-api/2026/10/20/req_8k2m4q7x1z9c3v5b6n0p2r4t/0-output.jpeg",
      "content_type": "image/jpeg",
      "file_size": 1843200,
      "width": 1024,
      "height": 768,
      "stored": true
    }
  ],
  "error": null,
  "metrics": {
    "inference_seconds": 6.8
  },
  "urls": {
    "self": "https://api.doitong.com/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t",
    "cancel": "https://api.doitong.com/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t/cancel"
  }
}
```

### Output fields (`output`)

| Field | Type | Description |
|---|---|---|
| `images` | array of object {url, content_type, file_name, file_size, width, height} | 生成画像のファイル情報。 |
| `seed` | integer | 画像生成シード。入力でシードを省略した場合はランダムに選ばれた値を含み、それ以外では指定値を繰り返します。 |
| `has_nsfw_concepts` | array of boolean | 生成画像に NSFW 概念が含まれるかどうかを示します。 |
| `debug_latents` | object {url, content_type, file_name, file_size} \| null | デバッグ用に保存する潜在データ。 |
| `debug_per_pass_latents` | object {url, content_type, file_name, file_size} \| null | デバッグ用に保存するパスごとの潜在データ。 |

## Related models

- [Stable Diffusion with LoRAs](https://doitong.com/developers/models/lora.md) (`lora`): $0.057 / image
- [Stable Diffusion with LoRAs · Image to Image](https://doitong.com/developers/models/lora/image-to-image.md) (`lora/image-to-image`): $0.264 / image
- [FLUX.1 Kontext \[pro\]](https://doitong.com/developers/models/flux-pro/kontext.md) (`flux-pro/kontext`): $0.04 / image
- [GPT Image 2.5 Edit](https://doitong.com/developers/models/openai/gpt-image-2.5/flare/edit.md) (`openai/gpt-image-2.5/flare/edit`): from $0.12 / image
- [Nano Banana 2 Edit](https://doitong.com/developers/models/nano-banana-2/edit.md) (`nano-banana-2/edit`): from $0.06 / image
- [Nano Banana Pro Edit](https://doitong.com/developers/models/nano-banana-pro/edit.md) (`nano-banana-pro/edit`): from $0.15 / image
- [Qwen Image 3 Edit](https://doitong.com/developers/models/alibaba/qwen-image-3/edit.md) (`alibaba/qwen-image-3/edit`): from $0.04 / image
- [Seedream 5.0 Pro Edit](https://doitong.com/developers/models/bytedance/seedream/v5/pro/edit.md) (`bytedance/seedream/v5/pro/edit`): from $0.0675 / run of output image

## Links

- HTML page: https://doitong.com/developers/models/lora/inpaint
- All models and guides for AI agents: https://doitong.com/developers/llms.txt
- OpenAPI 3.1 with this model's typed request body: https://doitong.com/developers/openapi.json?model=lora/inpaint
- Errors: https://doitong.com/developers/docs/errors
- Model details as JSON: https://api.doitong.com/v1/models/lora/inpaint
