# Stable Diffusion with LoRAs API

> Text-to-image cun mintga model da basa Stable Diffusion, plus LoRAs, embeddings, ControlNets e IP adapters

Generescha maletgs d'in prompt textual cun in model da basa inditgà tras URL u ID HuggingFace en `model_name`. Plirs `loras` pon vegnir fusiunads, e embeddings, ControlNets, IP adapters ed entradas IC Light èn sustegnidas. Las opziuns dal sampler includan blers schedulers e 1 fin a 150 pass. Generescha 1 fin a 8 maletgs en png u jpeg.

- Model id: `lora`
- Made by: Open model
- Category: Text to Image
- Output: image
- Estimated price per run: $0.057 / image (cheapest run $0.057 (57 API credits))
- Run: `POST https://api.doitong.ru/v1/run/lora`
- Quote: `POST https://api.doitong.ru/v1/quote/lora`
- Docs page: https://doitong.com/rm/developers/models/lora

## Pricing

Price: **$0.057 / 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.057 = 57 API credits (1 image × 57 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.ru/v1/quote/lora` 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 |  |  | Model da basa per generar la maletg, identifitgà tras in URL u in ID HuggingFace. |
| `unet_name` |  | string \| null | no |  |  | Selecziun U-Net persunalisada per generar maletgs; furnescha ses ID HuggingFace u sia URL. |
| `variant` |  | string \| null | no |  |  | Selecziun da la varianta dal model HuggingFace; 'fp16' è in exempel. |
| `prompt` |  | string | yes |  |  | Descriva il maletg che ti vuls generar, cun uschè blers detagls sco pussaivel per ils megliers resultats. |
| `negative_prompt` |  | string | no | `` |  | Prompt negativ che specifica detagls da maletg betg giavischads. El po excluder colurs, objects, cuntradas u caracteristicas e qualitads pli finas, sco ina mustazza, sfuschadad u ina resoluziun bassa. |
| `prompt_weighting` |  | boolean | no | `false` |  | Interrupziun da ponderaziun dal prompt: true removescha il limit da 77 token tras la mediaziun d’embeddings e activa la sintaxa da ponderaziun. |
| `loras` |  | array of object {path, scale} | no | `[]` |  | LoRAs da las qualas l'effect cumina produce il maletg generà, senza limit dal dumber furnì. |
| `loras[].path` |  | string | yes |  |  | Lieu dals pais da LoRA, specificà sco URL u percurs. |
| `loras[].scale` |  | number | no | `1` | 0 – 4 | Multiplicatur applitgà al pais da LoRA avant che quel vegn fusiunà en il model da basa. |
| `embeddings` |  | array of object {path, tokens} | no | `[]` |  | Embeddings applitgads durant la generaziun da maletgs per mappar ils token dal prompt a las ponderaziuns d’embedding. Actualmain è sustegnì mo in embedding. |
| `embeddings[].path` |  | string | yes |  |  | Ponderaziuns da l'embedding specifitgadas tras URL u tschep da datoteca. |
| `embeddings[].tokens` |  | array of string \| null | no |  |  | Ils token dal prompt vegnan mappads a ponderaziuns d’embedding. Sche vegnan omess, vegn creat in token per mintga vector dal datoteca d’embedding, numnads <s0>, <s1>, ...; utilisai ils token mappads en vos prompts. |
| `controlnets` |  | array of object {path, config_url, variant, image_url, mask_url, conditioning_scale, start_percentage, end_percentage, ip_adapter_index} | no | `[]` |  | Control nets planisads per l’applicaziun al maletg durant la generaziun, a timesteps spezificads, senza limit da quantas entradas che vegnan furnidas. |
| `controlnets[].path` |  | string | yes |  |  | Lieu da la ponderaziun ControlNet, inditgà sco URL u via. |
| `controlnets[].config_url` |  | string \| null | no |  |  | URL facultativ che mussa il datoteca config.json da ControlNet. |
| `controlnets[].variant` |  | string \| null | no |  |  | Varianta facultativa per l'utilisaziun cun ina clav da repositori Hugging Face. |
| `controlnets[].image_url` |  | string (image URL) | yes |  |  | URL dal maletg furnì sco input dal ControlNet. |
| `controlnets[].mask_url` |  | string (image URL) \| null | no |  |  | Masca dal ControlNet; sch’ella vegn furnida, sto ella avair la medema grondezza sco il maletg da controlla; ladezza ed autezza ston esser divisiblas cun 32. |
| `controlnets[].conditioning_scale` |  | number | no | `1` | 0 – 2 | Scalaziun applitgada a las ponderaziuns ControlNet avant ch'ellas vegnan fusiunadas cun il model da basa. |
| `controlnets[].start_percentage` |  | number | no | `0` | 0 – 1 | Per tschient dal total da pass temporals nua che ControlNet cumenza a influenzar la generaziun dal maletg. |
| `controlnets[].end_percentage` |  | number | no | `1` | 0 – 1 | Per tschient dal total da pass temporals nua che ControlNet chalenda d'influenzar la generaziun dal maletg. |
| `controlnets[].ip_adapter_index` |  | integer \| null | no |  |  | Selecziun da l’adapter IP tenor index per in ControlNet InstantID; auters ControlNets na dovran betg questa configuraziun. |
| `controlnet_guess_mode` |  | boolean | no | `false` |  | Limitescha l’applicaziun dal ControlNet a predicziuns cundiziunalas sch’il valur è true. |
| `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 | `[]` |  | Adapters IP utilisads per generar maletgs. Mintga entrada pretenda image_encoder_path. |
| `ip_adapter[].ip_adapter_image_url` |  | string (image URL) \| array of image URL | yes |  |  | URL dal maletg furnì sco input da l’adapter IP. |
| `ip_adapter[].ip_adapter_mask_url` |  | string (image URL) \| null | no |  |  | Masca da l’adapter IP; sch’ella vegn furnida, ston sias dimensiuns correspunder a quellas dal maletg da l’adapter. |
| `ip_adapter[].path` |  | string | yes |  |  | Lieu dals pais da l’adapter IP, inditgà sco URL u path. |
| `ip_adapter[].model_subfolder` |  | string \| null | no |  |  | Lieu dals pais da l’adapter IP, inditgà sco sutdatoteca en la datoteca dal model. |
| `ip_adapter[].weight_name` |  | string \| null | no |  |  | Num da la datoteca dals pais. |
| `ip_adapter[].insight_face_model_path` |  | string \| null | no |  |  | Lieu dals pais dal model InsightFace, inditgà sco URL u path. |
| `ip_adapter[].scale` |  | number | no | `1` | ≥ 0 | Factor da scala per ils pais da l’adapter IP, applitgà avant ch’els vegnan unids al model da basa. |
| `ip_adapter[].scale_json` |  | object \| null | no |  |  | Factor da scala per ils pais da l’adapter IP, applitgà avant ch’els vegnan unids al model da basa. |
| `ip_adapter[].unconditional_noising_factor` |  | number | no | `0` | 0 – 1 | Factor che controlla il noisiar nuncondiziunal per l’adapter IP. |
| `ip_adapter[].image_projection_shortcut` |  | boolean | no | `true` |  | Configuraziun dal shortcut da proiecziun dal maletg, cun True sco standard. Utilisai False per models FaceID plus V1 e True per models FaceID plus V2. |
| `image_encoder_path` |  | string \| null | no |  |  | Codader dal maletg inditgà tras ina URL HTTPS u in ID Hugging Face; la cumpatibilitad vegn determinada dals pais IP-Adapter: SD1.5 utilisescha image_encoder_subfolder='models/image_encoder', entant che h94/IP-Adapter SDXL utilisescha h94/IP-Adapter e image_encoder_subfolder='sdxl_models/image_encoder'. In codader è necessari sch’il valur da ip_adapter exista. |
| `image_encoder_subfolder` |  | string \| null | no |  |  | Sutdatoteca entaifer image_encoder_path che cuntegna ils pais dal codader dal maletg. |
| `image_encoder_weight_name` |  | string \| null | no | `pytorch_model.bin` |  | Tscherner ils pais dal codader dal maletg tenor num per generar maletgs. |
| `ic_light_model_url` |  | string \| null | no |  |  | URL dal model IC Light utilisà durant la generaziun da maletgs. |
| `ic_light_model_background_image_url` |  | string (image URL) \| null | no |  |  | Sfond cumpatibel cun il model per la generaziun da maletgs IC Light, furnì sco URL da maletg. |
| `ic_light_image_url` |  | string (image URL) \| null | no |  |  | URL dal maletg d’input per la generaziun cun il model IC Light. |
| `seed` |  | integer \| null | no |  |  | Seed per reproducir maletgs en Stable Diffusion. In maletg po vegnir reproducì exactamain en mintga execuziun sche la versiun dal model, il prompt ed il seed restan invariads. |
| `image_size` |  | object {width, height} \| enum (string) \| null | no | `square_hd` | `square_hd`, `square`, `portrait_4_3`, `portrait_16_9`, `landscape_4_3`, `landscape_16_9` | Dimensiuns dal maletg d'output, tschernidas da presets u inditgadas sco ladezza e autezza persunalizadas. Omaduas dimensiuns persunalizadas ston esser divisiblas cun 8. |
| `num_inference_steps` |  | integer | no | `30` | 1 – 150 | Controlla quants pass da generaziun Stable Diffusion exequescha; pass supplementars pon producir in maletg final pli detaglià. |
| `guidance_scale` |  | number | no | `7.5` | 0 – 20 | Furza d'aderenza al prompt per la selecziun dal maletg, exprimida sco CFG (Classifier Free Guidance). |
| `clip_skip` |  | integer | no | `0` | 0 – 2 | Omet ina part da la generaziun dal maletg per render pli svelt, cun resultats levamain differents. |
| `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` | Scheduler u sampler utilisà per denoisar il maletg. |
| `timesteps` |  | object {method, array} | no | `{"array":[],"method":"default"}` |  | Surdefiniziun dal plan da timesteps da denoisaziun, exclusiva cun sigmas. Senza surdefiniziun—la configuraziun standard—calculescha il scheduler ils timesteps da num_inference_steps; cun in plan persunalizà daventa num_inference_steps irrelevant. La surdefiniziun pretenda il sustegn dal scheduler per l’argument timesteps da set_timesteps. |
| `timesteps.method` |  | enum (string) | no | `default` | `default`, `array` | Tscherner co determinar ils timesteps: 'default', la configuraziun standard, permetta al scheduler d’utilisar `num_inference_steps`. Per furnir sez in plan, tschernai 'array' e mettai il plan en il champ `array`. |
| `timesteps.array` |  | array of integer | no | `[]` |  | Plan da timesteps applitgà sch’il metod tschernì è 'custom'. |
| `sigmas` |  | object {method, array} | no | `{"array":[],"method":"default"}` |  | Surdefiniziun dal plan da sigma da denoisaziun, exclusiva cun timesteps. Senza surdefiniziun—la configuraziun standard—calculescha il scheduler las sigmas da num_inference_steps; cun in plan persunalizà daventa num_inference_steps irrelevant. La surdefiniziun pretenda il sustegn dal scheduler per l’argument sigmas da set_sigmas. |
| `sigmas.method` |  | enum (string) | no | `default` | `default`, `array` | Tscherner co determinar las sigmas: 'default', la configuraziun standard, utilisescha ils agens valurs da sigma dal scheduler. Per furnir sez in plan, tschernai 'custom' e mettai il plan en il champ `array`. |
| `sigmas.array` |  | array of number | no | `[]` |  | Plan da sigma applitgà sch’il metod tschernì è 'custom'. |
| `prediction_type` |  | enum (string) | no | `epsilon` | `v_prediction`, `epsilon` | Tscherner il tip da predicziun per generar maletgs; senza in’autra selecziun vegn utilisà `epsilon`. |
| `rescale_betas_snr_zero` |  | boolean | no | `false` |  | Controlla sch’il sampler activa rescale_betas_snr_zero. |
| `image_format` |  | enum (string) | no | `png` | `jpeg`, `png` | Format da datoteca dal maletg final. |
| `num_images` | `num_outputs` | integer | no | `1` | 1 – 8 | Definir quants maletgs che ina singula dumonda producescha; in batch pli grond permetta dapli temp da generaziun. |
| `enable_safety_checker` |  | boolean | no | `false` |  | Activaziun da la controlla da segirezza; true activa la controlla. |
| `tile_width` |  | integer | no | `4096` | 128 – 4,096 | Definir la grondezza da mintga tile durant la generaziun da maletgs. |
| `tile_height` |  | integer | no | `4096` | 128 – 4,096 | Definir la grondezza da mintga tile durant la generaziun da maletgs. |
| `tile_stride_width` |  | integer | no | `2048` | 64 – 2,048 | Definir la distanza tranter posiziuns successivas da tiles durant la generaziun da maletgs. |
| `tile_stride_height` |  | integer | no | `2048` | 64 – 2,048 | Definir la distanza tranter posiziuns successivas da tiles durant la generaziun da maletgs. |
| `eta` |  | number | no | `0` | 0 – 1 | Configuraziun Eta utilisada durant la generaziun da maletgs. |
| `debug_latents` |  | boolean | no | `false` |  | Memorisar ils latents per il debugging sch’il valur è true. |
| `debug_per_pass_latents` |  | boolean | no | `false` |  | Activar il debugging per mintga pass cun definir true; quai memorisescha ils latents da mintga pass. |

File parameters (`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.ru/v1/run/lora?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.ru/v1/requests/REQUEST_ID?wait=20" \
  -H "Authorization: Bearer $DOITONG_API_KEY"
```

### JavaScript

```javascript
const API = "https://api.doitong.ru/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?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.ru/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", 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.ru/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",
      "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",
  "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": 57,
    "usd": "0.057",
    "charged": 57,
    "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.ru/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t",
    "cancel": "https://api.doitong.ru/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t/cancel"
  }
}
```

### Output fields (`output`)

| Field | Type | Description |
|---|---|---|
| `images` | array of object {url, content_type, file_name, file_size, width, height} | Infurmaziuns da la datoteca per ils maletgs generads. |
| `seed` | integer | Seed da la generaziun dal maletg, inclusa la valur tschernida casualmain sche l'input n'ha betg furnì in seed; autramain repeta la valur furnida. |
| `has_nsfw_concepts` | array of boolean | Inditgescha sche concepts NSFW cumparan en ils maletgs generads. |
| `debug_latents` | object {url, content_type, file_name, file_size} \| null | Datas latentas memorisadas per il debugging. |
| `debug_per_pass_latents` | object {url, content_type, file_name, file_size} \| null | Datas latentas per pass memorisadas per il debugging. |

## Related models

- [Stable Diffusion with LoRAs · Image to Image](https://doitong.com/developers/models/lora/image-to-image.md) (`lora/image-to-image`): $0.264 / image
- [Stable Diffusion with LoRAs · Inpaint](https://doitong.com/developers/models/lora/inpaint.md) (`lora/inpaint`): $0.184 / image
- [FLUX.1 \[dev\]](https://doitong.com/developers/models/flux/dev.md) (`flux/dev`): $0.025 / megapixel
- [FLUX.1 \[schnell\]](https://doitong.com/developers/models/flux/schnell.md) (`flux/schnell`): $0.003 / megapixel
- [FLUX.2 \[dev\]](https://doitong.com/developers/models/flux-2.md) (`flux-2`): $0.012 / megapixel
- [FLUX.2 \[pro\]](https://doitong.com/developers/models/flux-2-pro.md) (`flux-2-pro`): $0.015 / megapixel of output image
- [GPT Image 2.5 Text to Image](https://doitong.com/developers/models/openai/gpt-image-2.5/flare/text-to-image.md) (`openai/gpt-image-2.5/flare/text-to-image`): from $0.008 / image
- [Ideogram V4.5](https://doitong.com/developers/models/ideogram/v4.5.md) (`ideogram/v4.5`): from $0.03 / image

## Links

- HTML page: https://doitong.com/developers/models/lora
- 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
- Errors: https://doitong.com/developers/docs/errors
- Model details as JSON: https://api.doitong.ru/v1/models/lora
