# Stable Diffusion with LoRAs API

> Stable Diffusion အခြေခံမော်ဒယ်တစ်ခုခုနှင့် LoRAs၊ embeddings၊ ControlNets နှင့် IP adapters များကို အသုံးပြု၍ စာသားမှပုံဖန်တီးခြင်း

`model_name` ရှိ URL သို့မဟုတ် HuggingFace ID ဖြင့် သတ်မှတ်ထားသော အခြေခံမော်ဒယ်ကို အသုံးပြု၍ စာသားပရောမ့်မှ ပုံများကို ဖန်တီးသည်။ `loras` အများအပြားကို ပေါင်းစပ်နိုင်ပြီး Embedding၊ ControlNets၊ IP adapters နှင့် IC Light ထည့်သွင်းချက်များကို ပံ့ပိုးသည်။ ဆမ်ပလင်းရွေးချယ်စရာများတွင် scheduler များစွာနှင့် 1 မှ 150 အထိ အဆင့်များ ပါဝင်သည်။ png သို့မဟုတ် jpeg ဖြင့် ပုံ 1 မှ 8 ပုံအထိ ဖန်တီးသည်။

- 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.com/v1/run/lora`
- Quote: `POST https://api.doitong.com/v1/quote/lora`
- Docs page: https://doitong.com/my/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.com/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 |  |  | ပုံဖန်တီးရန် အခြေခံမော်ဒယ်၊ URL သို့မဟုတ် HuggingFace ID ဖြင့် သတ်မှတ်သည်။ |
| `unet_name` |  | string \| null | no |  |  | ပုံဖန်တီးရန် custom U-Net ရွေးချယ်မှု။ ၎င်း၏ HuggingFace ID သို့မဟုတ် URL တစ်ခုကို ပေးပါ။ |
| `variant` |  | string \| null | no |  |  | HuggingFace မော်ဒယ် variant ရွေးချယ်မှု။ 'fp16' သည် ဥပမာတစ်ခု ဖြစ်သည်။ |
| `prompt` |  | string | yes |  |  | ဖန်တီးလိုသောပုံကို အသေးစိတ်နိုင်သမျှ အသေးစိတ်ဖော်ပြပါ၊ ထိုသို့ပြုလုပ်ခြင်းဖြင့် အကောင်းဆုံးရလဒ် ရရှိမည်။ |
| `negative_prompt` |  | string | no | `` |  | မလိုလားသော ပုံအသေးစိတ်များကို သတ်မှတ်သည့် အနုတ်လက္ခဏာ ပရောမ့်။ အရောင်များ၊ အရာဝတ္ထုများ၊ ရှုခင်းများ သို့မဟုတ် နှုတ်ခမ်းမွှေး၊ ဝါးခြင်း၊ ရုပ်ထွက်အရည်အသွေး နိမ့်ခြင်းကဲ့သို့သော အသေးစိတ်အင်္ဂါရပ်များနှင့် အရည်အသွေးများကို ဖယ်ရှားနိုင်သည်။ |
| `prompt_weighting` |  | boolean | no | `false` |  | ပရောမ့် weighting toggle။ true ဖြစ်ပါက embedding averaging ဖြင့် 77 တိုကင်ကန့်သတ်ချက်ကို ဖယ်ရှားပြီး weighting syntax ကို ဖွင့်ပေးသည်။ |
| `loras` |  | array of object {path, scale} | no | `[]` |  | ပေါင်းစပ်အကျိုးသက်ရောက်မှုဖြင့် ဖန်တီးထားသော ပုံကို ထုတ်ပေးသည့် LoRA များ။ ပေးနိုင်သည့်အရေအတွက် ကန့်သတ်မထားပါ။ |
| `loras[].path` |  | string | yes |  |  | URL သို့မဟုတ် path အဖြစ် သတ်မှတ်ထားသော LoRA weights တည်နေရာ။ |
| `loras[].scale` |  | number | no | `1` | 0 – 4 | အခြေခံမော်ဒယ်သို့ မပေါင်းစပ်မီ LoRA weight တွင် အသုံးပြုသော multiplier။ |
| `embeddings` |  | array of object {path, tokens} | no | `[]` |  | ပရောမ့်တိုကင်များကို embedding weight များသို့ map ပြုလုပ်ရန် ပုံဖန်တီးမှုအတွင်း အသုံးပြုသည့် embeddings။ လက်ရှိတွင် embedding တစ်ခုသာ ပံ့ပိုးထားသည်။ |
| `embeddings[].path` |  | string | yes |  |  | URL သို့မဟုတ် ဖိုင်လမ်းကြောင်းဖြင့် သတ်မှတ်ထားသော Embedding weights။ |
| `embeddings[].tokens` |  | array of string \| null | no |  |  | embedding weight များသို့ map ပြုလုပ်ထားသော ပရောမ့်တိုကင်များ။ မပေးထားပါက embedding-file vector တစ်ခုလျှင် တိုကင်တစ်ခု ဖန်တီးပြီး <s0>, <s1>, ... ဟု အမည်ပေးသည်။ သင့်ပရောမ့်များတွင် map ပြုလုပ်ထားသော တိုကင်များကို အသုံးပြုပါ။ |
| `controlnets` |  | array of object {path, config_url, variant, image_url, mask_url, conditioning_scale, start_percentage, end_percentage, ip_adapter_index} | no | `[]` |  | ဖန်တီးမှုအတွင်း သတ်မှတ်ထားသော timestep များတွင် ပုံသို့ အသုံးချရန် စီစဉ်ထားသော control net များ။ ပေးနိုင်သည့်အရေအတွက် ကန့်သတ်ချက်မရှိပါ။ |
| `controlnets[].path` |  | string | yes |  |  | ControlNet အလေးချိန် တည်နေရာကို URL သို့မဟုတ် path အဖြစ် သတ်မှတ်သည်။ |
| `controlnets[].config_url` |  | string \| null | no |  |  | ControlNet ၏ config.json ဖိုင်သို့ ညွှန်ပြနိုင်သော ရွေးချယ်စရာ URL။ |
| `controlnets[].variant` |  | string \| null | no |  |  | Hugging Face repository key နှင့် အသုံးပြုရန် ရွေးချယ်နိုင်သော မူကွဲ။ |
| `controlnets[].image_url` |  | string (image URL) | yes |  |  | ControlNet ထည့်သွင်းချက် အဖြစ် ပေးသော ပုံ URL။ |
| `controlnets[].mask_url` |  | string (image URL) \| null | no |  |  | ControlNet mask ဖြစ်ပြီး ပေးထားပါက control ပုံ နှင့် အရွယ်အစားတူရမည်။ width နှင့် height တစ်ခုစီသည် 32 ဖြင့် စားလို့ပြတ်ရမည်။ |
| `controlnets[].conditioning_scale` |  | number | no | `1` | 0 – 2 | ControlNet အလေးချိန်များကို အခြေခံမော်ဒယ်ထဲသို့ ပေါင်းစည်းမီ အသုံးပြုသည့် စကေးချိန်ညှိမှု။ |
| `controlnets[].start_percentage` |  | number | no | `0` | 0 – 1 | ControlNet က ပုံဖန်တီးမှုအပေါ် စတင်သက်ရောက်သည့် စုစုပေါင်း timestep များ၏ ရာခိုင်နှုန်း။ |
| `controlnets[].end_percentage` |  | number | no | `1` | 0 – 1 | ControlNet က ပုံဖန်တီးမှုအပေါ် သက်ရောက်မှုရပ်တန့်သည့် စုစုပေါင်း timestep များ၏ ရာခိုင်နှုန်း။ |
| `controlnets[].ip_adapter_index` |  | integer \| null | no |  |  | InstantID ControlNet အတွက် index ဖြင့် IP adapter ရွေးချယ်မှု။ အခြား ControlNet များတွင် ဤ setting မလိုအပ်ပါ။ |
| `controlnet_guess_mode` |  | boolean | no | `false` |  | true ဖြစ်ပါက ControlNet အသုံးချမှုကို conditional prediction များတွင်သာ ကန့်သတ်သည်။ |
| `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 adapters များ။ မည်သည့် entry မဆို ပေးပါက 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 mask ဖြစ်ပြီး ၎င်း၏အတိုင်းအတာများသည် adapter ပုံ၏အတိုင်းအတာများနှင့် တူညီရမည်။ |
| `ip_adapter[].path` |  | string | yes |  |  | URL သို့မဟုတ် path အဖြစ် သတ်မှတ်ထားသော IP adapter weights တည်နေရာ။ |
| `ip_adapter[].model_subfolder` |  | string \| null | no |  |  | မော်ဒယ် directory အတွင်းရှိ subfolder အဖြစ် သတ်မှတ်ထားသော IP adapter weight တည်နေရာ။ |
| `ip_adapter[].weight_name` |  | string \| null | no |  |  | Weights ၏ ဖိုင်အမည်။ |
| `ip_adapter[].insight_face_model_path` |  | string \| null | no |  |  | URL သို့မဟုတ် path အဖြစ် သတ်မှတ်ထားသော InsightFace မော်ဒယ် weights တည်နေရာ။ |
| `ip_adapter[].scale` |  | number | no | `1` | ≥ 0 | Base မော်ဒယ် ထဲသို့ ပေါင်းစပ်မည့်မတိုင်မီ အသုံးပြုသော IP adapter weights ၏ scaling factor။ |
| `ip_adapter[].scale_json` |  | object \| null | no |  |  | Base မော်ဒယ် ထဲသို့ ပေါင်းစပ်မည့်မတိုင်မီ အသုံးပြုသော IP adapter weights ၏ scaling factor။ |
| `ip_adapter[].unconditional_noising_factor` |  | number | no | `0` | 0 – 1 | IP adapter အတွက် unconditional noising ကို ထိန်းချုပ်သည့် factor။ |
| `ip_adapter[].image_projection_shortcut` |  | boolean | no | `true` |  | မူလတန်ဖိုးအဖြစ် True သတ်မှတ်ထားသော ပုံ projection shortcut setting။ FaceID plus V1 မော်ဒယ်များအတွက် False နှင့် FaceID plus V2 မော်ဒယ်များအတွက် True ကို အသုံးပြုပါ။ |
| `image_encoder_path` |  | string \| null | no |  |  | HTTPS URL သို့မဟုတ် Hugging Face ID ဖြင့် သတ်မှတ်သော ပုံ encoder ဖြစ်သည်။ လိုက်ဖက်မှုကို IP-Adapter weights က သတ်မှတ်ပြီး SD1.5 သည် image_encoder_subfolder='models/image_encoder' ကို အသုံးပြုကာ h94/IP-Adapter SDXL သည် h94/IP-Adapter နှင့် image_encoder_subfolder='sdxl_models/image_encoder' ကို အသုံးပြုသည်။ ip_adapter တွင် တန်ဖိုးတစ်ခု ပါရှိသည့်အခါတိုင်း encoder လိုအပ်သည်။ |
| `image_encoder_subfolder` |  | string \| null | no |  |  | ပုံ encoder weights ပါရှိသည့် image_encoder_path အတွင်းရှိ subdirectory။ |
| `image_encoder_weight_name` |  | string \| null | no | `pytorch_model.bin` |  | ပုံများဖန်တီးရန် အသုံးပြုမည့် ပုံ encoder ၏ weights ကို အမည်ဖြင့် ရွေးချယ်ပါ။ |
| `ic_light_model_url` |  | string \| null | no |  |  | ပုံများဖန်တီးရာတွင် အသုံးပြုသည့် IC Light မော်ဒယ် URL။ |
| `ic_light_model_background_image_url` |  | string (image URL) \| null | no |  |  | ပုံ URL အဖြစ် ပေးထားသော IC Light ပုံဖန်တီးမှုအတွက် မော်ဒယ်နှင့် လိုက်ဖက်သည့် နောက်ခံ။ |
| `ic_light_image_url` |  | string (image URL) \| null | no |  |  | IC Light မော်ဒယ်ဖြင့် ဖန်တီးရန် ထည့်သွင်းသည့် ပုံ URL။ |
| `seed` |  | integer \| null | no |  |  | Stable Diffusion တွင် ပုံများကို ပြန်လည်ထုတ်လုပ်ရန် seed။ မော်ဒယ်ဗားရှင်း၊ ပရောမ့်နှင့် seed ကို မပြောင်းလဲထားပါက run တိုင်း ပုံကို အတိအကျ ပြန်လည်ထုတ်လုပ်နိုင်သည်။ |
| `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` | ကြိုတင်သတ်မှတ်ချက်များမှ ရွေးချယ်ထားသော သို့မဟုတ် စိတ်ကြိုက် width နှင့် height သတ်မှတ်ထားသော ထွက်ရလဒ်ပုံအရွယ်အစား။ စိတ်ကြိုက်အရွယ်အစားနှစ်ခုစလုံးသည် 8 ဖြင့်စားလို့ပြတ်ရမည်။ |
| `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 | ပုံဖန်တီးမှု၏ တစ်စိတ်တစ်ပိုင်းကို ကျော်ကာ ပိုမြန်စွာ render လုပ်ပြီး အနည်းငယ်ကွဲပြားသော ရလဒ်များကို ထုတ်ပေးသည်။ |
| `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` | ပုံမှ noise ဖယ်ရှားရန် အသုံးပြုသည့် scheduler သို့မဟုတ် sampler။ |
| `timesteps` |  | object {method, array} | no | `{"array":[],"method":"default"}` |  | sigmas နှင့် အပြန်အလှန် သီးခြားဖြစ်သော denoising timestep schedule override။ Override မရှိပါက—မူလတန်ဖိုးအတိုင်း—scheduler သည် num_inference_steps မှ timesteps များကို တွက်ချက်သည်။ စိတ်ကြိုက် schedule ပေးပါက num_inference_steps သည် သက်ရောက်မှုမရှိတော့ပါ။ Override အသုံးပြုရန် set_timesteps ရှိ timesteps argument ကို scheduler က ထောက်ပံ့ရမည်။ |
| `timesteps.method` |  | enum (string) | no | `default` | `default`, `array` | timesteps များကို သတ်မှတ်ပုံ ရွေးချယ်ပါ။ 'default' သည် မူလ setting ဖြစ်ပြီး scheduler က `num_inference_steps` ကို အသုံးပြုစေသည်။ timestep schedule ကို ကိုယ်တိုင်ပေးရန် 'array' ကို ရွေးပြီး schedule ကို `array` field တွင် ထည့်ပါ။ |
| `timesteps.array` |  | array of integer | no | `[]` |  | ရွေးချယ်ထားသော method သည် 'custom' ဖြစ်သည့်အခါ အသုံးပြုသည့် Timestep schedule။ |
| `sigmas` |  | object {method, array} | no | `{"array":[],"method":"default"}` |  | timesteps နှင့် အပြန်အလှန် သီးခြားဖြစ်သော denoising sigma schedule override။ Override မရှိပါက—မူလတန်ဖိုးအတိုင်း—scheduler သည် num_inference_steps မှ sigmas များကို တွက်ချက်သည်။ စိတ်ကြိုက် schedule ပေးပါက num_inference_steps သည် သက်ရောက်မှုမရှိတော့ပါ။ Override အသုံးပြုရန် set_sigmas ရှိ sigmas argument ကို scheduler က ထောက်ပံ့ရမည်။ |
| `sigmas.method` |  | enum (string) | no | `default` | `default`, `array` | sigmas များကို သတ်မှတ်ပုံ ရွေးချယ်ပါ။ 'default' သည် မူလ setting ဖြစ်ပြီး scheduler ၏ ကိုယ်ပိုင် sigma တန်ဖိုးများကို အသုံးပြုသည်။ sigma schedule ကို ကိုယ်တိုင်ပေးရန် 'custom' ကို ရွေးပြီး schedule ကို `array` field တွင် ထည့်ပါ။ |
| `sigmas.array` |  | array of number | no | `[]` |  | ရွေးချယ်ထားသော method သည် 'custom' ဖြစ်သည့်အခါ အသုံးပြုသည့် Sigma schedule။ |
| `prediction_type` |  | enum (string) | no | `epsilon` | `v_prediction`, `epsilon` | ပုံများဖန်တီးရန် prediction type ကို ရွေးချယ်ပါ။ အခြားရွေးချယ်မှု မပြုလုပ်ပါက `epsilon` ကို အသုံးပြုသည်။ |
| `rescale_betas_snr_zero` |  | boolean | no | `false` |  | Sampler က rescale_betas_snr_zero ကို ဖွင့်မဖွင့် ထိန်းချုပ်သည်။ |
| `image_format` |  | enum (string) | no | `png` | `jpeg`, `png` | ရလဒ်ပုံအတွက် ဖိုင်ဖော်မတ်။ |
| `num_images` | `num_outputs` | integer | no | `1` | 1 – 8 | တောင်းဆိုချက်တစ်ခုတည်းက ထုတ်ပေးမည့် ပုံအရေအတွက်ကို သတ်မှတ်ပါ။ batch ပိုကြီးလေလေ ဖန်တီးချိန် ပိုမိုပေးနိုင်သည်။ |
| `enable_safety_checker` |  | boolean | no | `false` |  | လုံခြုံရေးစစ်ဆေးမှု ဖွင့်ခြင်း၊ true သည် စစ်ဆေးမှုကို ဖွင့်ပေးသည်။ |
| `tile_width` |  | integer | no | `4096` | 128 – 4,096 | ပုံဖန်တီးစဉ် tile တစ်ခုစီ၏ အရွယ်အစားကို သတ်မှတ်ပါ။ |
| `tile_height` |  | integer | no | `4096` | 128 – 4,096 | ပုံဖန်တီးစဉ် tile တစ်ခုစီ၏ အရွယ်အစားကို သတ်မှတ်ပါ။ |
| `tile_stride_width` |  | integer | no | `2048` | 64 – 2,048 | ပုံဖန်တီးစဉ် ဆက်တိုက် tile အနေအထားများကြားရှိ အကွာအဝေးကို သတ်မှတ်ပါ။ |
| `tile_stride_height` |  | integer | no | `2048` | 64 – 2,048 | ပုံဖန်တီးစဉ် ဆက်တိုက် tile အနေအထားများကြားရှိ အကွာအဝေးကို သတ်မှတ်ပါ။ |
| `eta` |  | number | no | `0` | 0 – 1 | ပုံများဖန်တီးရာတွင် အသုံးပြုသည့် Eta setting။ |
| `debug_latents` |  | boolean | no | `false` |  | true ဖြစ်ပါက debugging အတွက် latents များကို သိမ်းဆည်းသည်။ |
| `debug_per_pass_latents` |  | boolean | no | `false` |  | ၎င်းကို true သတ်မှတ်ခြင်းဖြင့် pass တစ်ခုစီအလိုက် debugging ကို ဖွင့်ပြီး pass တိုင်းမှ latents များကို သိမ်းဆည်းသည်။ |

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.com/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.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?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", 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",
      "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.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 | ပုံဖန်တီးမှုအတွက် seed၊ ထည့်သွင်းချက်တွင် seed မပါပါက ကျပန်းရွေးချယ်ထားသောတန်ဖိုးကို ပါဝင်စေပြီး၊ ပါရှိပါက ပေးထားသောတန်ဖိုးကို ထပ်မံအသုံးပြုသည်။ |
| `has_nsfw_concepts` | array of boolean | ဖန်တီးထားသောပုံများတွင် NSFW အယူအဆများ ပါဝင်ခြင်း ရှိ၊ မရှိ ဖော်ပြသည်။ |
| `debug_latents` | object {url, content_type, file_name, file_size} \| null | Debugging အတွက် သိမ်းဆည်းထားသော Latent data။ |
| `debug_per_pass_latents` | object {url, content_type, file_name, file_size} \| null | Debugging အတွက် သိမ်းဆည်းထားသော pass တစ်ခုစီအလိုက် latent data။ |

## 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.com/v1/models/lora
