Any ComfyUI workflow runs as a job, from the inputs its catalog entry declares
CI / test (push) Successful in 9m7s
CI / test (push) Successful in 9m7s
A model's catalog entry now says what its workflow takes and makes:
comfyui.inputs, each a placeholder of its name with a type (text, int,
float, bool, choice, image, mask, audio, video, file), bounds, choices
and a default; and comfyui.output, which gains video, audio and files
beside pictures and meshes. POST /v1/workflows/runs with {model, inputs}
checks a request against them before a job is written — a required input
left out, an unknown one, a number out of bounds, a song sent as a
picture, another owner's file id are each refused with what was wrong —
and the job worker replays it to a replica, where the files go into
ComfyUI's input directory, the workflow is filled and run, and the first
file of the model's output kind is the job's result. /v1/models lists
each ComfyUI model's workflow, so a client can build its form.
A PNG result carries the licence in an iTXt chunk, as a GLB does in
asset.extras. A file whose server named no type is typed by its name
before its bytes, so a WAV is audio/wav, not audio/wave.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
b43e66c95e
commit
b6bfc33ef7
20 files changed
+1660
-44
No files matched your search
@@ -258,9 +258,51 @@ type TokenCount struct {
|
||||
|
||||
// License is the terms what a model makes comes under.
|
||||
type License struct {
|
||||
// ID is SPDX where there is one, else the licence's own short name.
|
||||
ID string `json:"id,omitempty"`
|
||||
Name string `json:"name"`
|
||||
URL string `json:"url,omitempty"`
|
||||
Notice string `json:"notice,omitempty"`
|
||||
// Commercial is whether the output may be used commercially; absent is
|
||||
// not said.
|
||||
Commercial *bool `json:"commercial,omitempty"`
|
||||
// ExcludedRegions are ISO 3166 codes, EU for the union, where it grants
|
||||
// nothing.
|
||||
ExcludedRegions []string `json:"excluded_regions,omitempty"`
|
||||
RevenueCapUSD int64 `json:"revenue_cap_usd,omitempty"`
|
||||
Attribution string `json:"attribution,omitempty"`
|
||||
}
|
||||
|
||||
// WorkflowInfo is what a ComfyUI model takes and makes, for a run at
|
||||
// /v1/workflows/runs.
|
||||
type WorkflowInfo struct {
|
||||
// Output is pictures, meshes, video, audio or files.
|
||||
Output string `json:"output"`
|
||||
Inputs []WorkflowInput `json:"inputs"`
|
||||
}
|
||||
|
||||
// WorkflowInput is one input a workflow takes.
|
||||
type WorkflowInput struct {
|
||||
Name string `json:"name"`
|
||||
// Type is text, int, float, bool, choice, image, mask, audio, video or
|
||||
// file; the last five are sent as base64, a data URL, or a file's id.
|
||||
Type string `json:"type"`
|
||||
Required bool `json:"required,omitempty"`
|
||||
Default any `json:"default,omitempty"`
|
||||
Min *float64 `json:"min,omitempty"`
|
||||
Max *float64 `json:"max,omitempty"`
|
||||
Choices []string `json:"choices,omitempty"`
|
||||
MaxMB int `json:"max_mb,omitempty"`
|
||||
Doc string `json:"doc,omitempty"`
|
||||
}
|
||||
|
||||
// RunRequest asks a ComfyUI model to run its workflow.
|
||||
type RunRequest struct {
|
||||
Model string `json:"model"`
|
||||
// Inputs are by name, as the model's workflow lists them in /v1/models.
|
||||
Inputs map[string]any `json:"inputs"`
|
||||
// Seed is the workflow's {{seed}}, where it has one; random otherwise.
|
||||
Seed *int64 `json:"seed,omitempty"`
|
||||
}
|
||||
|
||||
// ModelInfo is a model a key may use.
|
||||
@@ -276,9 +318,11 @@ type ModelInfo struct {
|
||||
ContextLength int `json:"context_length,omitempty"`
|
||||
MaxOutputTokens int `json:"max_output_tokens,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
// Capabilities: tools, vision, embeddings, images, meshes.
|
||||
// Capabilities: tools, vision, embeddings, images, meshes, workflows.
|
||||
Capabilities map[string]bool `json:"capabilities"`
|
||||
License *License `json:"license,omitempty"`
|
||||
// Workflow is what a ComfyUI model takes and makes.
|
||||
Workflow *WorkflowInfo `json:"workflow,omitempty"`
|
||||
}
|
||||
|
||||
// ModelList is the models a key may use.
|
||||
|
||||
@@ -18,6 +18,7 @@ var PathParams = map[string]string{
|
||||
"files/{id}": "The file's ID, file-….",
|
||||
"batches/{id}": "The batch's ID, batch_….",
|
||||
"generations/{id}": "The job's ID, job_….",
|
||||
"runs/{id}": "The job's ID, job_….",
|
||||
"threads/{id}": "The conversation's ID, as sent in x-llmgw-thread.",
|
||||
"memory/{key}": "The note's key, chosen by the caller.",
|
||||
"collections/{id}": "The collection's ID, its name when that is unique, or ORG/NAME.",
|
||||
@@ -59,6 +60,18 @@ var Routes = []Route{
|
||||
Response: JobList{}},
|
||||
{Method: "GET", Path: "/v1/3d/generations/{id}", Summary: "A 3D job: its status, progress and result", Response: Job{}},
|
||||
{Method: "POST", Path: "/v1/3d/generations/{id}/cancel", Summary: "Stop a 3D job, in the engine's queue too", Response: Job{}},
|
||||
{Method: "POST", Path: "/v1/workflows/runs", Summary: "Run a ComfyUI model's workflow, as a job",
|
||||
Description: "Inputs are those the model's workflow lists in /v1/models. Answered 202 with the job; " +
|
||||
"download output_file_id from /v1/files once it is completed.",
|
||||
Request: RunRequest{}, Response: Job{}, Status: 202},
|
||||
{Method: "GET", Path: "/v1/workflows/runs", Summary: "The caller's jobs, newest first",
|
||||
Query: []Param{
|
||||
{Name: "limit", Type: "integer", Description: "The most jobs to answer with, at most 100; 20 when absent."},
|
||||
{Name: "after", Description: "A job's ID: those asked for before it."},
|
||||
},
|
||||
Response: JobList{}},
|
||||
{Method: "GET", Path: "/v1/workflows/runs/{id}", Summary: "A run: its status, progress and result", Response: Job{}},
|
||||
{Method: "POST", Path: "/v1/workflows/runs/{id}/cancel", Summary: "Stop a run, in the engine's queue too", Response: Job{}},
|
||||
{Method: "POST", Path: "/v1/moderations", Summary: "Texts judged by the guardrails' judge model",
|
||||
Request: ModerationRequest{}, Response: ModerationResponse{}},
|
||||
{Method: "POST", Path: "/v1/responses", Summary: "OpenAI's Responses API, for Codex and the like",
|
||||
|
||||
@@ -17,7 +17,8 @@ func routerRoutes(t *testing.T) []string {
|
||||
t.Helper()
|
||||
_, file, _, _ := runtime.Caller(0)
|
||||
dir := filepath.Join(filepath.Dir(file), "..", "router")
|
||||
consts := map[string]string{"imagesPath": "/v1/images/generations", "meshesPath": "/v1/3d/generations"}
|
||||
consts := map[string]string{"imagesPath": "/v1/images/generations", "meshesPath": "/v1/3d/generations",
|
||||
"workflowsPath": "/v1/workflows/runs"}
|
||||
literal := regexp.MustCompile(`mux\.HandleFunc\("([A-Z]+) (/[^"]*)"`)
|
||||
built := regexp.MustCompile(`mux\.HandleFunc\("([A-Z]+) "\+([A-Za-z]+Path)(\+"([^"]*)")?`)
|
||||
files, _ := filepath.Glob(filepath.Join(dir, "*.go"))
|
||||
|
||||
Reference in new issue
Block a user