{"id":22677796,"url":"https://github.com/stablecanvas/sd-webui-a1111-client","last_synced_at":"2026-02-28T17:02:34.511Z","repository":{"id":182505652,"uuid":"668607371","full_name":"StableCanvas/sd-webui-a1111-client","owner":"StableCanvas","description":"API client for AUTOMATIC111/stable-diffusion-webui for nodejs/browser","archived":false,"fork":false,"pushed_at":"2024-05-26T09:39:26.000Z","size":529,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-27T09:25:20.721Z","etag":null,"topics":["a1111-stable-diffusion-webui","a1111-webui","api","image-generation","image-generation-ai","js","sd","sdxl","stable-diffusion","stable-diffusion-webui","ts"],"latest_commit_sha":null,"homepage":"https://stablecanvas.github.io/sd-webui-a1111-client/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/StableCanvas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-20T07:48:55.000Z","updated_at":"2024-05-26T09:39:29.000Z","dependencies_parsed_at":"2024-05-27T12:19:10.013Z","dependency_job_id":null,"html_url":"https://github.com/StableCanvas/sd-webui-a1111-client","commit_stats":null,"previous_names":["stablecanvas/sd-webui-a1111-client"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StableCanvas%2Fsd-webui-a1111-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StableCanvas%2Fsd-webui-a1111-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StableCanvas%2Fsd-webui-a1111-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StableCanvas%2Fsd-webui-a1111-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StableCanvas","download_url":"https://codeload.github.com/StableCanvas/sd-webui-a1111-client/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248579325,"owners_count":21127798,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["a1111-stable-diffusion-webui","a1111-webui","api","image-generation","image-generation-ai","js","sd","sdxl","stable-diffusion","stable-diffusion-webui","ts"],"created_at":"2024-12-09T18:01:25.838Z","updated_at":"2026-02-28T17:02:28.828Z","avatar_url":"https://github.com/StableCanvas.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n# sd-webui-a1111-client\n\n[![npm](https://img.shields.io/npm/v/@stable-canvas/sd-webui-a1111-client)](https://www.npmjs.com/package/@stable-canvas/sd-webui-a1111-client)\n[![npm](https://img.shields.io/npm/dw/@stable-canvas/sd-webui-a1111-client)](https://www.npmjs.com/package/@stable-canvas/sd-webui-a1111-client)\n[![GitHub Repo stars](https://img.shields.io/github/stars/StableCanvas/sd-webui-a1111-client)](https://github.com/StableCanvas/sd-webui-a1111-client)\n\n\nAPI client for AUTOMATIC1111/stable-diffusion-webui for Node.js and Browser.\n\n- [Types Document](https://stablecanvas.github.io/sd-webui-a1111-client/)\n\n## Features\n\n- Full TypeScript support\n- Supports Node.js and browser environments\n- Extensions: ControlNet, Cutoff, DynamicCFG, TiledDiffusion, TiledVAE, agent scheduler\n- Batch processing support\n- Easy integration with popular extensions and models\n\n## Requisites \u0026 Supported Versions\n\n### Requisites\n\n- **Enable webui-api**: Use the `--api` command line argument.\n- **Disable webui-gui (optional)**: Use `--nowebui` to disable the web GUI.\n- \u003e You can find and modify the `COMMANDLINE_ARGS` value in the `webui-user.bat` or `webui-user.sh` file.\n\n### Supported Versions\n\n- **WebUI**: 1.10.1\n- **ControlNet**: 3b4eedd\n\n## Getting Started\n### Client Instance\n\n```ts\nimport { SDWebUIA1111Client } from \"@stable-canvas/sd-webui-a1111-client\";\n\nconst client = new SDWebUIA1111Client({\n  BASE: \"http://localhost:7860\",\n});\n```\n\n### Authentication\n\nUse the `--api-auth` command line argument with \"username:password\" on the server to enable API authentication.\n\n```ts\nconst client = new SDWebUIA1111Client({\n  BASE: \"http://localhost:7860\",\n  USERNAME: 'your_username',\n  PASSWORD: 'your_password'\n});\n```\n\n### Default Service\n\nAllowing full control over the request body.\n\n```ts\nconst response = await client.default.text2ImgapiSdapiV1Txt2ImgPost({\n  requestBody: {\n    prompt: 'an astronaut riding a horse on the moon'\n  }\n});\n```\n\nfully functions here:\n[Service Functions](https://stablecanvas.github.io/sd-webui-a1111-client/classes/DefaultService.html)\n\n## Pipeline Usage  \n\nThe `pipeline` is a DSL implementation in this library that allows intuitive request initiation through simple chained calls. It makes using the `sd-webui` client extremely straightforward.  \n\nHere is a basic example:  \n\n```ts\nimport { Pipeline } from \"@stable-canvas/sd-webui-a1111-client\";\nconst client = /* client instance */;\nconst { images, parameters } = await new Pipeline(client)\n  .model(\"sdxl.safetensors\")\n  .prompt(\"A beautiful sunset over the mountains\")\n  .negative(\"Low quality, blurry\")\n  .sampler(\"DPM++ 2M\")\n  .scheduler(\"exponential\")\n  .size(1024, 768)\n  .steps(35)\n  .cfg(5)\n  .use(/* extension */)\n  .run();\n```\n\n\u003e For details about extensions, refer to the **Processor Usage** section.\n\n### img2img (or inpainting) with pipeline\n```ts\nconst input_image = fs.readFileSync(\"./input_image.jpg\").toString(\"base64\");\nconst input_mask = fs.readFileSync(\"./input_mask.jpg\").toString(\"base64\");\nconst { images, parameters } = await new Pipeline(client)\n  .model(\"sdxl.safetensors\")\n  .prompt(\"A beautiful sunset over the mountains\")\n  .negative(\"Low quality, blurry\")\n  .sampler(\"DPM++ 2M\")\n  .scheduler(\"exponential\")\n  .size(1024, 768)\n  .steps(35)\n  .cfg(5)\n  .images(input_image)\n  // 👇 inpainting params 👇\n  // .inpainting(InpaintFill.original)\n  // .mask(input_mask)\n  .use(/* extension */)\n  .run();\n```\n\n## API Usage\n\n### Documentation\n\n[ServiceApi documentation](https://stablecanvas.github.io/sd-webui-a1111-client/classes/ServiceApi.html)\n\n### Instance\n\nUse the `A1111StableDiffusionApi` object for a high-level API client with optimized types and parameter handling.\n\n```ts\nconst api = new A1111StableDiffusionApi({\n  client: {\n    BASE: 'http://127.0.0.1:7860',\n    // USERNAME: 'your_username',\n    // PASSWORD: 'your_password'\n  },\n  // optional caching\n  // cache: {\n  //   disableCache: false,\n  //   cacheTime: 60 * 1000\n  // }\n});\n```\n\n### txt2img\n\n```ts\nconst { image, info } = await api.Service.txt2img({\n  prompt: '1girl'\n});\n```\n\n### img2img\n\n```ts\nconst { image, info } = await api.Service.img2img({\n  prompt: '1girl'\n});\n```\n\n### Batch Generation\n\nUse `txt2imgBatch` and `img2imgBatch` for batch processing.\n\n```ts\nconst batch = api.Service.txt2imgBatch(\n  { /* ... */ },\n  {\n    batchSize: 2,\n    numBatches: 10\n  }\n);\n\nconst responses = await batch.waitForComplete();\n```\n\n### ControlNet Api Usage\n\n[ControlNetApi documentation](http://stablecanvas.github.io/sd-webui-a1111-client/classes/ControlNetApi.html)\n\n### Requisites\n\n- Correct installation of [ControlNet Extension](https://github.com/Mikubill/sd-webui-controlnet)\n- Install required [ControlNet Models](https://huggingface.co/lllyasviel/ControlNet)\n\n### txt2img with ControlNet\n\n```ts\nconst { image, info } = await api.ControlNet.txt2img({\n  params: {\n    prompt: '...',\n    // ...\n  },\n  units: [\n    {\n      image: '...', // base64 string\n      module: 'openpose_full',\n      model: 'control_v11p_sd15_openpose [cab727d4]'\n    }\n  ]\n});\n```\n\n### img2img with ControlNet\n\n```ts\nconst { image, info } = await api.ControlNet.img2img({\n  params: {\n    prompt: '...',\n    // ...\n  },\n  units: [\n    {\n      image: '...', // base64 string\n      module: 'openpose_full',\n      model: 'control_v11p_sd15_openpose [cab727d4]'\n    }\n  ]\n});\n```\n\n### ControlNet Batch Generation\n\n```ts\nconst batch = api.ControlNet.txt2imgBatch({\n  params: { /* ... */ },\n  options: {\n    batchSize: 2,\n    numBatches: 10\n  },\n  units: [\n    {\n      image: '...', // base64 string\n      module: 'openpose_full',\n      model: 'control_v11p_sd15_openpose [cab727d4]'\n    }\n  ]\n});\n\nconst responses = await batch.waitForComplete();\n```\n\n### Detect\n\nThanks to the ControlNet plugin releasing an interface for detection, we can use this API when we only need to detect and not generate images.\n\n\u003e It is worth mentioning that if you want to customize the preprocessing process of ControlNet, you need to set the `module` parameter of the ControlNet Unit to `none`, indicating that the input image has already been preprocessed.\n\n\u003e Regarding the parameters `controlnet_threshold_a` and `controlnet_threshold_b`, you can use `api.ControlNet.getModuleDetail` to get the requirements for these parameters from the current plugin.\n\n```ts\nconst {\n  images,\n} = await api.ControlNet.detect({\n  controlnet_module: 'openpose_full',\n  controlnet_input_images: [\n    // image base64\n  ],\n  controlnet_processor_res: 512,\n});\n```\n\n### GetModelList\n\n```ts\nconst modelList = await api.ControlNet.getModels();\n```\n\n### GetModuleList\n\n```ts\nconst moduleList = await api.ControlNet.getModules();\n```\n\n## Processor Usage\nAdvanced processing pipeline, providing more control over requests.\n\n- [img2img documentation](http://stablecanvas.github.io/sd-webui-a1111-client/classes/Img2imgProcess.html)\n- [txt2img documentation](http://stablecanvas.github.io/sd-webui-a1111-client/classes/Txt2imgProcess.html)\n\n\u003e The design of the processor lies between the API and the client. It is not as convenient as the API but offers more customized functionalities, which is useful for achieving workflows similar to ComfyUI.\n\n### Text to Image / Image to Image\n\n```ts\nconst response = await client.default.text2ImgapiSdapiV1Txt2ImgPost({\n  requestBody: {\n    prompt: 'an astronaut riding a horse on the moon'\n  }\n});\nconst { images: [img] } = response;\n\nconst buffer = Buffer.from(img, \"base64\");\nawait fs.promises.writeFile('result.png', buffer);\n```\n\n### Cutoff Extension\n\n```ts\nconst pc1 = new Txt2imgProcess({ prompt: \"1girl, black top, short pink hair\" });\npc1.use(new CutoffExt({ targets: 'black, pink' }));\nconst { images } = await pc1.request(client);\n```\n\n### ControlNet Extension\n```ts\nconst input_image = fs.readFileSync('input_image.png', 'base64');\nconst pc1 = new Img2imgProcess({ prompt: \"1girl\", init_images: [input_image]});\n\nconst cnet_ext = new ControlNetExt();\ncnet_ext.addUnit({\n  model: 'openpose_full',\n  module: 'control_v11p_sd15_openpose [cab727d4]',\n  weight: 1,\n  pixel_perfect: true,\n});\n\npc1.use(cnet_ext);\nconst { images } = await pc1.request(client);\n```\n\n## Browser Usage\n\n### CDN links\n\n| Type      | unpkg                                                                                                      | jsdelivr                                                                                               |\n|-----------|------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------|\n| **mjs**   | [unpkg (mjs)](https://unpkg.com/@stable-canvas/sd-webui-a1111-client@latest/dist/main.module.mjs)           | [jsdelivr (mjs)](https://cdn.jsdelivr.net/npm/@stable-canvas/sd-webui-a1111-client@latest/+esm)       |\n| **umd**   | [unpkg (umd)](https://unpkg.com/@stable-canvas/sd-webui-a1111-client@latest/dist/main.umd.min.js)          | [jsdelivr (umd)](https://cdn.jsdelivr.net/npm/@stable-canvas/sd-webui-a1111-client@latest/dist/main.umd.min.js) |\n\n### Usage Example\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n  \u003cscript type=\"importmap\"\u003e\n    {\n      \"imports\": {\n        \"@stable-canvas/sd-webui-a1111-client\": \"https://unpkg.com/@stable-canvas/sd-webui-a1111-client@latest/dist/main.module.mjs\"\n      }\n    }\n  \u003c/script\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003ch1\u003e@stable-canvas/sd-webui-a1111-client DEMO\u003c/h1\u003e\n  \u003cdiv id=\"message\"\u003e\u003c/div\u003e\n  \u003cimg src=\"\" alt=\"result\" /\u003e\n  \u003cscript type=\"module\"\u003e\n    import { SDWebUIA1111Client, Txt2imgProcess } from \"@stable-canvas/sd-webui-a1111-client\";\n    \n    window.onload = async () =\u003e {\n      const $msg = document.querySelector(\"#message\");\n      const $img = document.querySelector(\"img\");\n      \n      const client = new SDWebUIA1111Client({ BASE: \"http://localhost:7860\" });\n      const pc1 = new Txt2imgProcess({ prompt: \"1girl\" });\n      \n      $msg.innerText = \"Generating...\";\n      \n      try {\n        const { images } = await pc1.request(client);\n        const image = images[0];\n        \n        $img.src = `data:image/png;base64,${image}`;\n        $msg.innerText = \"Done.\";\n      } catch (error) {\n        $msg.innerText = error.message;\n        console.error(error);\n      }\n    };\n  \u003c/script\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n## Example Code\n\n- Full code is available in the [/examples](https://github.com/your-repo/examples) folder.\n- Online demo: [CodeSandbox](https://codesandbox.io/s/sd-webui-a1111-client-demo-j38wmy?file=/src/index.js)\n\n## License\n\nApache-2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstablecanvas%2Fsd-webui-a1111-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstablecanvas%2Fsd-webui-a1111-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstablecanvas%2Fsd-webui-a1111-client/lists"}