comfy

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package comfy is the HTTP client for ComfyUI's native API.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnreachable = errors.New("comfyui unreachable")

ErrUnreachable marks a transport failure: ComfyUI is down, restarting, or the connection broke. Handlers map it to 503 upstream_unreachable.

Functions

This section is empty.

Types

type Client

type Client struct {
	Base string
	HTTP *http.Client
}

Client talks to one ComfyUI. Requests carry no overall timeout, only a connect timeout, matching the reference: /view can stream large outputs and a history call against a busy server can be slow.

func New

func New(base, token string) *Client

New returns a client for base, a URL with no trailing slash. A non-empty token is sent as a bearer token on every request to ComfyUI, the WebSocket handshake included, for a ComfyUI behind an authenticating gateway.

func (*Client) Do

func (c *Client) Do(ctx context.Context, method, path string, body any) (*Response, error)

Do sends a request and reads the whole reply. A body value is sent as JSON.

func (*Client) GetJSON

func (c *Client) GetJSON(ctx context.Context, path string) (json.RawMessage, bool, error)

GetJSON fetches path and returns its JSON body. ok is false when the reply was not a 200 JSON body, which callers treat as "nothing there". A body that is not valid JSON is reported as unreachable, since the server on the other end is not behaving as ComfyUI. Callers decode the raw body into the shape they expect and treat a shape mismatch as absent, as the reference's isinstance checks do.

func (*Client) PostMultipart

func (c *Client) PostMultipart(ctx context.Context, path, contentType string, body io.Reader) (*Response, error)

PostMultipart sends a prebuilt multipart body.

func (*Client) Size

func (c *Client) Size(ctx context.Context, path string) (size int64, ok bool, err error)

Size asks for path with HEAD and returns its Content-Length. ok is false when the reply was not a 200 with a length, which callers read as unknown.

func (*Client) Stream

func (c *Client) Stream(ctx context.Context, path string, header http.Header) (*http.Response, error)

Stream opens a request and hands back the live response for the caller to copy and close. Used for /view, where outputs can be large.

type Response

type Response struct {
	Status      int
	ContentType string // media type without parameters
	Body        []byte
}

Response is a fully read upstream reply.

func (*Response) IsJSON

func (r *Response) IsJSON() bool

IsJSON reports whether the reply declared a JSON body.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL