Documentation
¶
Overview ¶
Package comfy is the HTTP client for ComfyUI's native API.
Index ¶
- Variables
- type Client
- func (c *Client) Do(ctx context.Context, method, path string, body any) (*Response, error)
- func (c *Client) GetJSON(ctx context.Context, path string) (json.RawMessage, bool, error)
- func (c *Client) PostMultipart(ctx context.Context, path, contentType string, body io.Reader) (*Response, error)
- func (c *Client) Size(ctx context.Context, path string) (size int64, ok bool, err error)
- func (c *Client) Stream(ctx context.Context, path string, header http.Header) (*http.Response, error)
- type Response
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
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) GetJSON ¶
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.