{"id":26334426,"url":"https://github.com/lts8989/comfyui-go-api","last_synced_at":"2025-09-02T01:34:33.411Z","repository":{"id":280796781,"uuid":"943126580","full_name":"lts8989/comfyui-go-api","owner":"lts8989","description":"an example program for comfyui-go-sdk.","archived":false,"fork":false,"pushed_at":"2025-03-07T09:57:38.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-16T07:27:39.783Z","etag":null,"topics":["api","comfyui","example","golang","sdk","websocket"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lts8989.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2025-03-05T07:59:05.000Z","updated_at":"2025-03-07T10:01:47.000Z","dependencies_parsed_at":"2025-03-05T11:29:53.836Z","dependency_job_id":"0db2f826-d290-43bf-bc93-261592ff8ce1","html_url":"https://github.com/lts8989/comfyui-go-api","commit_stats":null,"previous_names":["lts8989/sd_api","lts8989/comfyui-go-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lts8989/comfyui-go-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lts8989%2Fcomfyui-go-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lts8989%2Fcomfyui-go-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lts8989%2Fcomfyui-go-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lts8989%2Fcomfyui-go-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lts8989","download_url":"https://codeload.github.com/lts8989/comfyui-go-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lts8989%2Fcomfyui-go-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273218426,"owners_count":25065913,"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-01T02:00:09.058Z","response_time":120,"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":["api","comfyui","example","golang","sdk","websocket"],"created_at":"2025-03-16T00:18:54.146Z","updated_at":"2025-09-02T01:34:33.400Z","avatar_url":"https://github.com/lts8989.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ComfyUI API\n\nComfyUI API 是 [ComfyUI SDK](https://github.com/lts8989/comfyui-go-sdk) 项目的示例应用。项目使用 `gin` 框架，提供了 RESTful API 接口，同时启动一个 `websocket` 连接到 `ComfyUI` 接收绘图任务进度推送。\n\n## 安装与运行\n\n### 安装\n\n    go get github.com/lts8989/comfyui-go-api\n\n### 运行前准备\n\n1. 可访问的 `ComfyUI` 服务，记下域名，后面要用到。\n2. 可用的 `mysql` 数据库。使用 [init.sql](utils/migrations/init.sql) 初始化数据表。\n3. 数据库用户名密码等信息和 `ComfyUI` 的域名写到配置文件中 [config.json](conf/config.yaml)。\n\n### 运行\n\n    go run main.go\n\n## 详细功能\n\napi 访问示例参考[api.http](test/api.http)\n\n### 绘图任务下发\n\nComfyUI 服务的绘图任务为json字符串。我们将任务以模板的形式存储在txt文件中，使用json参数填充到模板并发送到 ComfyUI 服务。例如参数为\n```json\n{\n  \"seed\": \"4259488860108327\",\n  \"steps\": \"2\"\n}\n```\n程序会将 `\u003c%seed%\u003e` 替换为 `4259488860108327`。模板可在 `ComfyUI` 的 web 界面中调试完成后导出，如下图。\n\n![](asdfasdf)\n\n模板文件保存在 [prompt_temp](prompt_temp)文件夹。\n\n模板数据保存在 templates 表。\n\n### 接收任务进度推送\n\n绘图任务的状态变更以 websocket 的形式实时推送到当前程序。请定义 `model.ReceivedMsgFun` 类型的方法以接收推送消息。当前项目中会将任务状态实时更新到任务表。如果任务执行结束，则下载执行结果中的图片到本地 [img](img) 文件夹。\n\n`websocket` 连接每30s会 `ping` 一次 `ComfyUI` 服务，如果断开连接，每 5s 尝试重连。如果因为 `websocket`\n断开连接导致错过了任务的执行结果的推送，可以手动调用查询任务执行结果接口获取任务执行状态以及结果。\n\n### 查询任务执行结果\n\n使用任务下发接口的任务id，查询执行结果，如果没有下载过图片，则再次下载图片。\n\n### ComfyUI 服务探活\n\n返回 ComfyUI 服务的服务器信息以及 ComfyUI 版本信息等。\n\n## 遗留的问题\n\n- 因为任务下发后，还没有等到 `ComfyUI` 服务返回任务id，`websocket` 就已经接收到新任务进度推送。导致在数据库中查不到任务数据，可能造成当前项目中任务状态与 `ComfyUI` 服务任务状态不一致。\n- 目前没有实现用户认证和权限控制。\n\n## ps\n\n* 项目大部分代码使用 `LLM` 生成\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flts8989%2Fcomfyui-go-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flts8989%2Fcomfyui-go-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flts8989%2Fcomfyui-go-api/lists"}