mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-06-17 21:39:45 +08:00
Provides formal validation and documentation for ComfyUI's /prompt API format. Changes: - schemas/prompt.json: Complete JSON Schema for prompt validation - Validates node structure with class_type and inputs - Supports direct values and node links [node_id, output_index] - Includes examples for common workflows - docs/api/prompt-schema.md: Comprehensive documentation - Usage examples and validation guide - Workflow vs Prompt format comparison - Common node type reference - Future enhancement roadmap Benefits: - Enables IDE autocomplete and validation - Provides clear API specification - Foundation for future dynamic schemas - Resolves confusion about workflow vs prompt formats Fixes #8899 [Bounty]
114 lines
2.9 KiB
JSON
114 lines
2.9 KiB
JSON
{
|
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
"$id": "https://github.com/comfyanonymous/ComfyUI/schemas/prompt.json",
|
|
"title": "ComfyUI Prompt API Format",
|
|
"description": "JSON Schema for ComfyUI /prompt API endpoint",
|
|
"type": "object",
|
|
"required": ["prompt"],
|
|
"properties": {
|
|
"prompt": {
|
|
"type": "object",
|
|
"description": "The prompt structure containing nodes",
|
|
"additionalProperties": {
|
|
"$ref": "#/definitions/node"
|
|
}
|
|
},
|
|
"extra_data": {
|
|
"type": "object",
|
|
"description": "Optional extra data for the prompt execution"
|
|
},
|
|
"client_id": {
|
|
"type": "string",
|
|
"description": "Optional client identifier"
|
|
}
|
|
},
|
|
"definitions": {
|
|
"node": {
|
|
"type": "object",
|
|
"required": ["class_type", "inputs"],
|
|
"properties": {
|
|
"class_type": {
|
|
"type": "string",
|
|
"description": "The node class type (e.g., KSampler, CLIPTextEncode, etc.)"
|
|
},
|
|
"inputs": {
|
|
"type": "object",
|
|
"description": "Input parameters for the node",
|
|
"additionalProperties": {
|
|
"oneOf": [
|
|
{
|
|
"description": "Direct value (string, number, boolean, array, object)"
|
|
},
|
|
{
|
|
"$ref": "#/definitions/nodeLink"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"_meta": {
|
|
"type": "object",
|
|
"description": "Optional metadata for the node"
|
|
}
|
|
},
|
|
"additionalProperties": false
|
|
},
|
|
"nodeLink": {
|
|
"type": "array",
|
|
"description": "Reference to another node's output",
|
|
"items": [
|
|
{
|
|
"type": "string",
|
|
"description": "The node_id of the source node"
|
|
},
|
|
{
|
|
"type": "integer",
|
|
"description": "The output index (0 for first output)"
|
|
}
|
|
],
|
|
"minItems": 2,
|
|
"maxItems": 2
|
|
}
|
|
},
|
|
"examples": [
|
|
{
|
|
"prompt": {
|
|
"3": {
|
|
"class_type": "KSampler",
|
|
"inputs": {
|
|
"seed": 123456789,
|
|
"steps": 20,
|
|
"cfg": 8.0,
|
|
"sampler_name": "euler",
|
|
"scheduler": "normal",
|
|
"denoise": 1.0,
|
|
"model": ["4", 0],
|
|
"positive": ["6", 0],
|
|
"negative": ["7", 0],
|
|
"latent_image": ["5", 0]
|
|
}
|
|
},
|
|
"4": {
|
|
"class_type": "CheckpointLoaderSimple",
|
|
"inputs": {
|
|
"ckpt_name": "model.safetensors"
|
|
}
|
|
},
|
|
"6": {
|
|
"class_type": "CLIPTextEncode",
|
|
"inputs": {
|
|
"text": "beautiful scenery nature glass bottle landscape, purple galaxy bottle",
|
|
"clip": ["4", 1]
|
|
}
|
|
},
|
|
"7": {
|
|
"class_type": "CLIPTextEncode",
|
|
"inputs": {
|
|
"text": "text, watermark",
|
|
"clip": ["4", 1]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|