{"id":20855690,"url":"https://github.com/spensercai/sd-webui-go","last_synced_at":"2025-09-25T15:40:11.440Z","repository":{"id":187820187,"uuid":"677655818","full_name":"SpenserCai/sd-webui-go","owner":"SpenserCai","description":"This is a Go language version of the SDK based on stable-diffusion-webui. In your code, you can directly use the API interfaces of stable-diffusion-webui through object-oriented operations, instead of dealing with cumbersome JSON.  Support extensions API !","archived":false,"fork":false,"pushed_at":"2024-03-25T10:10:59.000Z","size":3929,"stargazers_count":347,"open_issues_count":1,"forks_count":6,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-09-24T05:46:41.945Z","etag":null,"topics":["ai","aigc","api","golang","sd-webui","sdk","stable-diffusion","stable-diffusion-webui","webui"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SpenserCai.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-08-12T07:29:06.000Z","updated_at":"2025-09-14T20:03:16.000Z","dependencies_parsed_at":"2023-12-18T03:25:27.371Z","dependency_job_id":"473f2e05-d1aa-4987-9ffb-1223b5b0d97e","html_url":"https://github.com/SpenserCai/sd-webui-go","commit_stats":null,"previous_names":["spensercai/sd-webui-go"],"tags_count":29,"template":false,"template_full_name":null,"purl":"pkg:github/SpenserCai/sd-webui-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpenserCai%2Fsd-webui-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpenserCai%2Fsd-webui-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpenserCai%2Fsd-webui-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpenserCai%2Fsd-webui-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SpenserCai","download_url":"https://codeload.github.com/SpenserCai/sd-webui-go/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpenserCai%2Fsd-webui-go/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276714448,"owners_count":25691396,"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","status":"online","status_checked_at":"2025-09-24T02:00:09.776Z","response_time":97,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["ai","aigc","api","golang","sd-webui","sdk","stable-diffusion","stable-diffusion-webui","webui"],"created_at":"2024-11-18T04:20:20.783Z","updated_at":"2025-09-25T15:40:11.404Z","avatar_url":"https://github.com/SpenserCai.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\n * @Author: SpenserCai\n * @Date: 2023-08-12 01:27:12\n * @version: \n * @LastEditors: SpenserCai, drgrib\n * @LastEditTime: 2023-09-13 10:51:18\n * @Description: file content\n--\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n\u003cimg src=\"https://raw.githubusercontent.com/SpenserCai/sd-webui-go/main/res/logo.png\" width=\"200\" height=\"200\" alt=\"sd-webui-go\"\u003e\n\n# SD-WEBUI-GO\nGolang SDK for [stable-diffusion-webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui)'s API\n\n**Among the contributors is AUTOMATIC1111, a little joke on my part😂.**\n\n**Here,sincerely thank AUTOMATIC1111 for its great contribution to AIGC**\n\n\u003c/div\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://raw.githubusercontent.com/SpenserCai/sd-webui-go/main/LICENSE\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/license/SpenserCai/sd-webui-go?color=blueviolet\" alt=\"license\"\u003e\n  \u003c/a\u003e\n  \u003cimg src=\"https://img.shields.io/badge/Go-1.19+-blue\" alt=\"go\"\u003e\n  \u003ca href=\"https://github.com/SpenserCai/sd-webui-go/releases\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/v/release/SpenserCai/sd-webui-go?color=rgb(255%2C0%2C0)\u0026include_prereleases\" alt=\"release\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://goreportcard.com/report/github.com/SpenserCai/sd-webui-go\"\u003e\n    \u003cimg src=\"https://goreportcard.com/badge/github.com/SpenserCai/sd-webui-go\" alt=\"GoReportCard\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://discord.gg/nN6b7QAcVW\"\u003e\n  \u003cimg src=\"https://discordapp.com/api/guilds/1140177489008807966/widget.png?style=shield\" alt=\"Discord Server\"\u003e\n\u003c/a\u003e\n\u003c/p\u003e\n\nThis is a Go language version of the SDK based on [stable-diffusion-webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui). In your code, you can directly use the API interfaces of [stable-diffusion-webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui) through object-oriented operations, instead of dealing with cumbersome JSON.\n\nSupport extensions API !\n\n\u003cb\u003eYou can check the support list for intersvc in this [wiki page](https://github.com/SpenserCai/sd-webui-go/wiki/Intersvc-Support-List).\u003c/b\u003e\n\n## Usage\nThere are two methods to use the SDK. \n\n - Using 'intersvc', which provides a highly encapsulated API interface for 'sd-webui'. Using this method feels like directly using the Go language version of 'sd-webui'. \n\n - Using 'go-swagger', which still involves object-oriented operations but is slightly more complex than 'intersvc'. \n\nAlmost all interfaces are supported by the second method, while the first one is gradually being supported.\n\nIn fact, most of the interfaces can be used with 'intersvc', but it requires defining the Response. The API documentation of 'sd-webui' does not provide the content of the Response, so it needs to be defined manually. You can refer to the \"Participating\" section below for specific instructions.\n\n### go-swagger text2img\n\n```go\npackage main\n\nimport (\n\t\"encoding/base64\"\n\t\"fmt\"\n\n\tSdClient \"github.com/SpenserCai/sd-webui-go\"\n\tSdApiOperation \"github.com/SpenserCai/sd-webui-go/stablediffusion/client/operations\"\n\tSdApiModel \"github.com/SpenserCai/sd-webui-go/stablediffusion/models\"\n)\n\nfunc MustBeNil(err error) {\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n\nvar URL = \"127.0.0.1:7860\"\n\nfunc main() {\n\tsdClient := SdClient.NewStableDiffInterface(URL)\n\n\trd := SdApiOperation.NewText2imgapiSdapiV1Txt2imgPostParams()\n\trd.Body = \u0026SdApiModel.StableDiffusionProcessingTxt2Img{\n\t\tPrompt:         \"dog\",\n\t\tNegativePrompt: \"ugly\",\n\t\tScriptArgs:     []interface{}{},\n\t}\n\n\tresp, err := sdClient.Client.Operations.Text2imgapiSdapiV1Txt2imgPost(rd)\n\tMustBeNil(err)\n\n\tfor i, s := range resp.Payload.Images {\n\t\tb, err := base64.StdEncoding.DecodeString(s)\n\t\tMustBeNil(err)\n\t\terr = os.WriteFile(fmt.Sprintf(\"%d.png\", i), b, 0644)\n\t\tMustBeNil(err)\n\t}\n}\n```\n\n### intersvc deoldify\n\n```go\nimport (\n\tSdClient \"github.com/SpenserCai/sd-webui-go\"\n\t\"github.com/SpenserCai/sd-webui-go/intersvc\"\n)\n\nfunc main() {\n\t// Create a client\n\tsdClient := SdClient.NewStableDiffInterface(\"127.0.0.1:7860\")\n\n\tvar f_factor int64 = 20\n\tvar artistic bool = false\n\n\t// Set Request\n\tdeoldify_inter := \u0026intersvc.DeoldifyImage{\n\t\tRequestItem: \u0026intersvc.DeoldifyImageRequest{\n\t\t\tInputImage:   \"https://media.discordapp.net/attachments/1138408545277190237/1138508881635577947i7krs1njekla1.jpg\",\n\t\t\tRenderFactor: \u0026f_factor,\n\t\t\tArtistic:     \u0026artistic,\n\t\t},\n\t}\n\n\n\tdeoldify_inter.Action(sdClient)\n\tif deoldify_inter.Error != nil {\n\t\tpanic(deoldify_inter.Error)\n\t}\n\n\tresponse := deoldify_inter.GetResponse()\n}\n```\n\nFull example code: [intersvc_example](./examples/intersvc_demo/main.go)\n\n### go-swagger deoldify \n\n```go\nimport (\n\t\"encoding/base64\"\n\t\"os\"\n\t\n\tSdClient \"github.com/SpenserCai/sd-webui-go\"\n\tintersvc \"github.com/SpenserCai/sd-webui-go/intersvc\"\n\tSdApiOperation \"github.com/SpenserCai/sd-webui-go/stablediffusion/client/operations\"\n\tSdApiModel \"github.com/SpenserCai/sd-webui-go/stablediffusion/models\"\n)\n\ntype DeoldifyResponse struct {\n\tImage string `json:\"image\"`\n}\n\nfunc main() {\n\tvar (\n\t\terr error\n\t)\n\n\t// init client\n\tsdClient := SdClient.NewStableDiffInterface(\"127.0.0.1:7860\")\n\n\tvar f_factor int64 = 20\n\tvar artistic bool = false\n\n\t// set request data\n\tRequestData := SdApiOperation.NewDeoldifyImageDeoldifyImagePostParams()\n\tRequestData.Body = \u0026SdApiModel.BodyDeoldifyImageDeoldifyImagePost{\n\t\tInputImage:   \"https://media.discordapp.net/attachments/1138408545277190237/1138508881635577947/i7krs1njekla1.jpg\",\n\t\tRenderFactor: \u0026f_factor,\n\t\tArtistic:     \u0026artistic,\n\t}\n\n\t// send request\n\tResponse, err := sdClient.Client.Operations.DeoldifyImageDeoldifyImagePost(RequestData)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// convert response\n\tdeoldifyRep, err := intersvc.ConvertResponse(Response.Payload, \u0026DeoldifyResponse{})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n    response := deoldifyRep.(*DeoldifyResponse)\n}\n```\n\nFull example code: [go-swagger_example](./examples/stable_demo/main.go)\n\n## Participating\n\nMost of the code for intersvc has been generated using a code generator. However, due to the lack of response information in the API documentation for sd-webui, it needs to be manually written.\n\n### How to submit a PR\n\nYou need to fork the code of the dev branch, make the necessary code updates, create a branch named dev-[model filename] in your own repository, and then submit a pull request to the dev branch of this repository.\n\n### How to define the Response Model\n\nIn `sd-webui-go/intersvc`,you can see some file like `***_model.go`. These files define the Response Model. You can refer to the following example to define the Response Model.\n\nFrom\n\n```go\ntype DeoldifyImageResponse struct {\n\t\n}\n```\n\nTo\n\n```go\ntype DeoldifyImageResponse struct {\n\tImage string `json:\"image\"`\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspensercai%2Fsd-webui-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspensercai%2Fsd-webui-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspensercai%2Fsd-webui-go/lists"}