https://github.com/tanis2000/comfy-client
ComfyUI client library written in Go
https://github.com/tanis2000/comfy-client
api api-client api-client-go comfyui go golang stable-diffusion
Last synced: about 2 months ago
JSON representation
ComfyUI client library written in Go
- Host: GitHub
- URL: https://github.com/tanis2000/comfy-client
- Owner: tanis2000
- License: mit
- Created: 2024-06-06T17:24:52.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-06-07T19:14:33.000Z (about 2 years ago)
- Last Synced: 2025-01-10T09:33:52.412Z (over 1 year ago)
- Topics: api, api-client, api-client-go, comfyui, go, golang, stable-diffusion
- Language: Go
- Homepage:
- Size: 99.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ComfyUI Go client library
comfy-client is a REST/WS client library for [ComfyUI](https://github.com/comfyanonymous/ComfyUI) written in Go.
The aim is to provide an easy way to interface with the REST and WebSocket based API offered by ComfyUI.
This is still in early development. Contributions are welcome.
# Basic usage
```go
package main
import (
"encoding/json"
"fmt"
"github.com/tanis2000/comfy-client/client"
"github.com/tanis2000/comfy-client/graph"
"github.com/tanis2000/comfy-client/workflow"
"io"
"log"
"os"
)
func main() {
callbacks := &client.Callbacks{
OnStatus: func(c *client.Client, queuedItems int) {
log.Printf("Queue size: %d", queuedItems)
},
}
c, err := client.NewClient("localhost", 8188, callbacks)
if err != nil {
panic(err)
}
println("Loading JSON workflow API")
f, err := os.Open("examples/txt2img/txt2img_api.json")
if err != nil {
panic(err)
}
content, err := io.ReadAll(f)
if err != nil {
panic(err)
}
err = f.Close()
if err != nil {
panic(err)
}
println("Building workflow from workflow api")
w, err := workflow.NewWorkflow(string(content))
if err != nil {
panic(err)
}
println("Enqueueing a prompt")
res, err := c.QueuePrompt(-1, w)
if err != nil {
panic(err)
}
println(res)
println("Starting the message loop")
for continueLoop := true; continueLoop; {
msg := <-res.Messages
println(msg)
}
}
```
Examples of how to use this library can be found in [examples](examples)