跳至內容

Stable Diffusion with LoRAs

整合

模型 id lora
# 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"

此請求: ≈$0.057 57 API 點數 在此頁面執行

取得 API 金鑰
Open model 文字轉圖像 參考輸入 #diffusion#lora#customization

使用任何 Stable Diffusion 基礎模型,支援 LoRA、嵌入向量、ControlNets 與 IP adapters 的文字生成圖像

Open model · 圖像

您的第一個結果會顯示在這裡

在下方建立請求,並使用您的 API 金鑰執行。輸出會複製到我們的儲存空間,可永久保留或免費保留 7 天。

建立請求

控制項是根據模型結構描述生成的。變更設定時,程式碼和價格會同步更新。

•必填

盡可能詳細地描述想要生成的圖像,以取得最佳結果。

image_size 預設 square_hd

輸出圖像尺寸,可從預設值選取或自訂寬度與高度。兩個自訂尺寸都必須可被 8 整除。

•必填

用於生成圖像的基礎模型,以 URL 或 HuggingFace ID 識別。

num_images 預設 1

設定單一請求生成的圖像數量,較大的批次會需要更長的生成時間。

進階 negative_prompt · ic_light_model_background_image_url · ic_light_image_url · prediction_type · image_format · unet_name · variant · image_encoder_path · image_encoder_subfolder · image_encoder_weight_name · ic_light_model_url · scheduler · num_inference_steps · guidance_scale · clip_skip · tile_width · tile_height · tile_stride_width · tile_stride_height · eta · seed · prompt_weighting · controlnet_guess_mode · rescale_betas_snr_zero · enable_safety_checker · debug_latents · debug_per_pass_latents · loras · embeddings · controlnets · ip_adapter · timesteps · sigmas
預設

指定不需要圖像細節的負面提示詞。可排除色彩、物件、景物或更細微的特徵與品質,例如鬍鬚、模糊或低解析度。

拖放檔案,或

IC Light 圖像生成所需、與模型相容的背景,以圖像 URL 提供。

拖放檔案,或

使用 IC Light 模型生成時的輸入圖像 URL。

prediction_type 預設 epsilon

選擇生成圖像的預測類型;未另行選擇時使用 `epsilon`。

image_format 預設 png

生成圖像的檔案格式。

用於生成圖像的自訂 U-Net 選擇;請提供其 HuggingFace ID 或 URL。

HuggingFace 模型變體選擇;'fp16' 是其中一個範例。

以 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_path 中存放圖像編碼器權重的子目錄。

預設 pytorch_model.bin

依名稱選取用於生成圖像的圖像編碼器權重。

生成圖像時使用的 IC Light 模型 URL。

用於對圖像去噪的排程器或取樣器。

預設 30

控制 Stable Diffusion 執行的生成步驟數;增加步驟可能產生更詳細的最終圖像。

預設 7.5

圖像選取的提示詞遵循強度,以 CFG (Classifier Free Guidance) 表示。

預設 0

略過部分圖像生成以加快渲染速度,結果會略有不同。

預設 4096

設定圖像生成期間每個圖塊的大小。

預設 4096

設定圖像生成期間每個圖塊的大小。

預設 2048

設定圖像生成期間連續圖塊位置之間的間距。

預設 2048

設定圖像生成期間連續圖塊位置之間的間距。

預設 0

生成圖像時使用的 Eta 設定。

用於在 Stable Diffusion 中重現圖像的種子。只要模型版本、提示詞和種子保持不變,每次執行都能精確重現圖像。

預設 []

其組合效果會產生生成圖像的 LoRA,數量不限。

預設 []

在圖像生成期間套用的嵌入,用於將提示詞 Token 對應至嵌入權重。目前僅支援一個嵌入。

預設 []

生成期間在指定時間步驟套用至圖像的 ControlNet,可提供任意數量。

預設 []

用於生成圖像的 IP adapter。提供任何項目都需要 image_encoder_path。

預設 {"array":[],"method":...

去噪時間步驟排程覆寫,與 sigmas 互斥。未覆寫時(預設),排程器會從 num_inference_steps 計算時間步驟;提供自訂排程後,num_inference_steps 不再適用。覆寫需要排程器支援 set_timesteps 的 timesteps 引數。

預設 {"array":[],"method":...

去噪 sigma 排程覆寫,與 timesteps 互斥。未覆寫時(預設),排程器會從 num_inference_steps 計算 sigma;提供自訂排程後,num_inference_steps 不再適用。覆寫需要排程器支援 set_sigmas 的 sigmas 引數。

POST /run/lora?wait=20 報價 → $0.057
# 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"

執行此請求

您的金鑰會保留在此瀏覽器中:只會傳送至 Doitong API,且只有在勾選「記住」時才會儲存至 localStorage。 取得 API 金鑰

關於 Stable Diffusion with LoRAs

使用由 URL 或 HuggingFace ID 在 `model_name` 中指定的基礎模型,根據文字提示詞生成圖像。可合併多個 `loras`,並支援嵌入向量、ControlNets、IP adapters 與 IC Light 輸入。取樣器選項包含許多排程器,步驟範圍為 1 到 150。可生成 1 到 8 張 png 或 jpeg 圖像。

參數

請傳送標準名稱或原生名稱其中之一,不要同時傳送兩者。 標準名稱

名稱類型 預設值允許值 說明
model_name必填
類型string
用於生成圖像的基礎模型,以 URL 或 HuggingFace ID 識別。
unet_name選填
類型string | null
用於生成圖像的自訂 U-Net 選擇;請提供其 HuggingFace ID 或 URL。
variant選填
類型string | null
HuggingFace 模型變體選擇;'fp16' 是其中一個範例。
prompt必填
類型string
盡可能詳細地描述想要生成的圖像,以取得最佳結果。
negative_prompt選填
類型string
預設值
指定不需要圖像細節的負面提示詞。可排除色彩、物件、景物或更細微的特徵與品質,例如鬍鬚、模糊或低解析度。
prompt_weighting選填
類型boolean
預設值false
提示詞加權切換:true 會透過嵌入平均移除 77 Token 限制,並啟用加權語法。
loras選填
類型object[]
預設值[]
其組合效果會產生生成圖像的 LoRA,數量不限。
loras[].path必填
類型string
LoRA 權重的位置,以 URL 或路徑指定。
loras[].scale選填
類型number
預設值1
0 – 4
合併至基礎模型前套用至 LoRA 權重的倍數。
embeddings選填
類型object[]
預設值[]
在圖像生成期間套用的嵌入,用於將提示詞 Token 對應至嵌入權重。目前僅支援一個嵌入。
embeddings[].path必填
類型string
由 URL 或檔案路徑指定的嵌入權重。
embeddings[].tokens選填
類型string[]
對應至嵌入權重的提示詞 Token。省略時,會為每個嵌入檔案向量建立一個 Token,名稱為 <s0>、<s1>、...;請在提示詞中使用對應的 Token。
controlnets選填
類型object[]
預設值[]
生成期間在指定時間步驟套用至圖像的 ControlNet,可提供任意數量。
controlnets[].path必填
類型string
ControlNet 權重位置,可指定為 URL 或路徑。
controlnets[].config_url選填
類型string | null
可選的 URL,指向 ControlNet 的 config.json 檔案。
controlnets[].variant選填
類型string | null
搭配 Hugging Face 儲存庫金鑰使用的可選變體。
controlnets[].image_url必填
類型url · image
作為 ControlNet 輸入的圖像 URL。
controlnets[].mask_url選填
類型url · image
ControlNet 遮罩;提供時必須與控制圖像尺寸相同,寬度和高度都必須可被 32 整除。
controlnets[].conditioning_scale選填
類型number
預設值1
0 – 2
ControlNet 權重合併至基礎模型前套用的縮放。
controlnets[].start_percentage選填
類型number
預設值0
0 – 1
ControlNet 開始影響圖像生成時所占總時間步的百分比。
controlnets[].end_percentage選填
類型number
預設值1
0 – 1
ControlNet 停止影響圖像生成時所占總時間步的百分比。
controlnets[].ip_adapter_index選填
類型integer | null
InstantID ControlNet 的 IP adapter 索引選擇;其他 ControlNet 不需要此設定。
controlnet_guess_mode選填
類型boolean
預設值false
為 true 時,將 ControlNet 的套用限制為條件式預測。
ip_adapter選填
類型object[]
預設值[]
用於生成圖像的 IP adapter。提供任何項目都需要 image_encoder_path。
ip_adapter[].ip_adapter_image_url必填
類型url · image
作為 IP adapter 輸入的圖像 URL。
ip_adapter[].ip_adapter_mask_url選填
類型url · image
IP adapter 遮罩;提供時受尺寸限制,其尺寸必須與 adapter 圖像相同。
ip_adapter[].path必填
類型string
IP adapter 權重位置,以 URL 或路徑指定。
ip_adapter[].model_subfolder選填
類型string | null
IP adapter 權重位置,以模型目錄中的子資料夾指定。
ip_adapter[].weight_name選填
類型string | null
權重檔案名稱。
ip_adapter[].insight_face_model_path選填
類型string | null
InsightFace 模型權重位置,以 URL 或路徑指定。
ip_adapter[].scale選填
類型number
預設值1
≥ 0
IP adapter 權重的縮放係數,在合併至基礎模型前套用。
ip_adapter[].scale_json選填
類型object | null
IP adapter 權重的縮放係數,在合併至基礎模型前套用。
ip_adapter[].unconditional_noising_factor選填
類型number
預設值0
0 – 1
控制 IP adapter 無條件加噪的係數。
ip_adapter[].image_projection_shortcut選填
類型boolean
預設值true
圖像投影捷徑設定,預設為 True。FaceID plus V1 模型使用 False,FaceID plus V2 模型使用 True。
image_encoder_path選填
類型string | null
以 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
image_encoder_path 中存放圖像編碼器權重的子目錄。
image_encoder_weight_name選填
類型string | null
預設值pytorch_model.bin
依名稱選取用於生成圖像的圖像編碼器權重。
ic_light_model_url選填
類型string | null
生成圖像時使用的 IC Light 模型 URL。
ic_light_model_background_image_url選填
類型url · image
IC Light 圖像生成所需、與模型相容的背景,以圖像 URL 提供。
ic_light_image_url選填
類型url · image
使用 IC Light 模型生成時的輸入圖像 URL。
seed選填
類型integer | null
用於在 Stable Diffusion 中重現圖像的種子。只要模型版本、提示詞和種子保持不變,每次執行都能精確重現圖像。
image_size選填
類型object
預設值square_hd
square_hdsquareportrait_4_3portrait_16_9landscape_4_3landscape_16_9
輸出圖像尺寸,可從預設值選取或自訂寬度與高度。兩個自訂尺寸都必須可被 8 整除。
num_inference_steps選填
類型integer
預設值30
1 – 150
控制 Stable Diffusion 執行的生成步驟數;增加步驟可能產生更詳細的最終圖像。
guidance_scale選填
類型number
預設值7.5
0 – 20
圖像選取的提示詞遵循強度,以 CFG (Classifier Free Guidance) 表示。
clip_skip選填
類型integer
預設值0
0 – 2
略過部分圖像生成以加快渲染速度,結果會略有不同。
scheduler選填
類型enum
DPM++ 2MDPM++ 2M KarrasDPM++ 2M SDEDPM++ 2M SDE KarrasEulerEuler AEuler (trailing timesteps)LCMLCM (trailing timesteps)DDIMTCD
用於對圖像去噪的排程器或取樣器。
timesteps選填
類型object
預設值{"array":[],"method":"default"}
去噪時間步驟排程覆寫,與 sigmas 互斥。未覆寫時(預設),排程器會從 num_inference_steps 計算時間步驟;提供自訂排程後,num_inference_steps 不再適用。覆寫需要排程器支援 set_timesteps 的 timesteps 引數。
timesteps.method選填
類型enum
預設值default
defaultarray
選擇決定時間步驟的方式:'default'(預設設定)讓排程器使用 `num_inference_steps`。若要自行提供時間步驟排程,請選取 'array' 並將排程放入 `array` 欄位。
timesteps.array選填
類型integer[]
預設值[]
所選方法為 'custom' 時套用的時間步驟排程。
sigmas選填
類型object
預設值{"array":[],"method":"default"}
去噪 sigma 排程覆寫,與 timesteps 互斥。未覆寫時(預設),排程器會從 num_inference_steps 計算 sigma;提供自訂排程後,num_inference_steps 不再適用。覆寫需要排程器支援 set_sigmas 的 sigmas 引數。
sigmas.method選填
類型enum
預設值default
defaultarray
選擇決定 sigma 的方式:'default'(預設設定)使用排程器自身的 sigma 值。若要自行提供 sigma 排程,請選取 'custom' 並將排程放入 `array` 欄位。
sigmas.array選填
類型number[]
預設值[]
所選方法為 'custom' 時套用的 sigma 排程。
prediction_type選填
類型enum
預設值epsilon
v_predictionepsilon
選擇生成圖像的預測類型;未另行選擇時使用 `epsilon`。
rescale_betas_snr_zero選填
類型boolean
預設值false
控制採樣器是否啟用 rescale_betas_snr_zero。
image_format選填
類型enum
預設值png
jpegpng
生成圖像的檔案格式。
num_images選填 num_outputs
類型integer
預設值1
1 – 8
設定單一請求生成的圖像數量,較大的批次會需要更長的生成時間。
enable_safety_checker選填
類型boolean
預設值false
安全檢查器啟用狀態;true 會啟用檢查。
tile_width選填
類型integer
預設值4096
128 – 4,096
設定圖像生成期間每個圖塊的大小。
tile_height選填
類型integer
預設值4096
128 – 4,096
設定圖像生成期間每個圖塊的大小。
tile_stride_width選填
類型integer
預設值2048
64 – 2,048
設定圖像生成期間連續圖塊位置之間的間距。
tile_stride_height選填
類型integer
預設值2048
64 – 2,048
設定圖像生成期間連續圖塊位置之間的間距。
eta選填
類型number
預設值0
0 – 1
生成圖像時使用的 Eta 設定。
debug_latents選填
類型boolean
預設值false
為 true 時儲存潛在變數以供偵錯。
debug_per_pass_latents選填
類型boolean
預設值false
設為 true 以啟用逐輪偵錯,並儲存每一輪的潛在變數。
必填 標準名稱,也可使用

檔案參數接受公開的 https:// URL、最大 10 MB 的 data: URI,或上傳檔案的 file_url。 檔案

輸出

GET /requests/req_8k2m4q7x1z9c3v5b6n0p2r4t
{
  "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"
  }
}
您的檔案,由您選擇每個 outputs[].url 都是儲存空間中的副本:可永久保留(按 GB-月計費),或免費保留 7 天;可透過帳戶設定或 ?storage= 設定。
所有模型使用相同結構圖片、影片和音訊皆包含 type、url、content_type、width、height 和 duration。output 是模型自己的結果物件。
輸出欄位
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儲存以供偵錯的逐輪潛在資料。

更多模型:文字轉圖像

給 AI 代理程式:此頁面的 Markdown 位於 https://doitong.com/zh-TW/developers/models/lora.md. 所有模型與指南: https://doitong.com/developers/llms.txt