mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-06-26 09:49:26 +08:00
docs: add API entry points for local script examples
This commit is contained in:
parent
739061dd4c
commit
2f28658204
@ -65,6 +65,14 @@ Supports all operating systems and GPU types (NVIDIA, AMD, Intel, Apple Silicon,
|
||||
## Examples
|
||||
See what ComfyUI can do with the [newer template workflows](https://comfy.org/workflows) or old [example workflows](https://comfyanonymous.github.io/ComfyUI_examples/).
|
||||
|
||||
## API
|
||||
|
||||
If you want to automate local ComfyUI runs or integrate it into another tool:
|
||||
|
||||
- `openapi.yaml` documents the newer `/api/*` endpoints, including `POST /api/prompt`, `GET /api/queue`, and `GET /api/jobs/{job_id}`.
|
||||
- [`script_examples/`](script_examples/README.md) contains small Python examples for the local scripting endpoints and websocket flow.
|
||||
- In the UI, use `File -> Export (API)` to export the current workflow in API format before sending it to the backend.
|
||||
|
||||
## Features
|
||||
- Nodes/graph/flowchart interface to experiment and create complex Stable Diffusion workflows without needing to code anything.
|
||||
- NOTE: There are many more models supported than the list below, if you want to see what is supported see our templates list inside ComfyUI.
|
||||
|
||||
44
script_examples/README.md
Normal file
44
script_examples/README.md
Normal file
@ -0,0 +1,44 @@
|
||||
# API Script Examples
|
||||
|
||||
This folder contains small Python examples for driving a local ComfyUI server from code.
|
||||
|
||||
## Files
|
||||
|
||||
- `basic_api_example.py`: submits a workflow exported from `File -> Export (API)`.
|
||||
- `websockets_api_example.py`: submits a workflow, waits for completion over websocket, and then fetches generated images from history.
|
||||
- `websockets_api_example_ws_images.py`: streams image bytes directly through the websocket with `SaveImageWebsocket` instead of saving files to disk first.
|
||||
|
||||
## What These Examples Use
|
||||
|
||||
These scripts target the local scripting routes exposed by `server.py`:
|
||||
|
||||
- `POST /prompt`
|
||||
- `GET /history/{prompt_id}`
|
||||
- `GET /queue`
|
||||
- `GET /view`
|
||||
- `GET /ws`
|
||||
|
||||
For the newer documented REST API, see [`openapi.yaml`](../openapi.yaml). In particular:
|
||||
|
||||
- `POST /api/prompt`
|
||||
- `GET /api/queue`
|
||||
- `GET /api/jobs/{job_id}`
|
||||
|
||||
## Usage Notes
|
||||
|
||||
1. Start ComfyUI locally, which defaults to `127.0.0.1:8188`.
|
||||
2. Load or create a workflow in the UI.
|
||||
3. Export the workflow with `File -> Export (API)`.
|
||||
4. Replace the sample `prompt_text` in one of these scripts with the exported JSON if needed.
|
||||
5. Make sure the referenced models and nodes are available in your local ComfyUI install.
|
||||
|
||||
## Dependencies
|
||||
|
||||
- `basic_api_example.py` uses only the Python standard library.
|
||||
- The websocket examples also require `websocket-client`.
|
||||
|
||||
Install it with:
|
||||
|
||||
```bash
|
||||
pip install websocket-client
|
||||
```
|
||||
Loading…
Reference in New Issue
Block a user