Loading...
Loading...
Optimize your Python web apps with ViewComfy API by following these rewritten rules for deploying workflows, handling parameters, API calls, cold starts, and outputs using httpx and FastAPI.
Follow these Do/Don't guidelines to integrate ViewComfy API—a serverless FastAPI service for ComfyUI workflows—into Python applications effectively.
**Do deploy your ComfyUI workflow first**
Upload workflow_api.json to the ViewComfy dashboard to get your unique endpoint.
Example:
```python
# Use dashboard to deploy, then set:
view_comfy_api_url = "https://your-endpoint.viewcomfy.com/api/infer"
```
**Don't call the API without API keys**
Always obtain and use client_id and client_secret from the dashboard.
Example:
```python
client_id = "your_client_id"
client_secret = "your_client_secret"
headers = {"client_id": client_id, "client_secret": client_secret}
```
**Do extract and flatten workflow parameters**
Run workflow_parameters_maker.py on workflow_api.json to identify editable inputs like prompts or images.
Example:
```bash
python workflow_parameters_maker.py --workflow_api_path "workflow_api.json"
```
Result: `{"6-inputs-text": "new prompt", "52-inputs-image": "path/to/image"}`
**Don't send empty params**
Include at least a seed change to avoid errors; update relevant keys for custom inputs.
Example:
```python
params = {"seed": 123456} # Minimum
params["6-inputs-text"] = "Custom prompt here"
params["52-inputs-image"] = open("image.png", "rb")
```
**Do account for cold starts and variable times**
First calls may delay due to startup (up to minutes); use timeouts like 2400s.
Example:
```python
import httpx
response = await client.post(url, timeout=httpx.Timeout(2400.0), ...)
```
**Do choose infer or infer_with_logs**
Use `infer` for simple POST; `infer_with_logs` for real-time ComfyUI progress via callback.
Example:
```python
def log_callback(message): print(message)
result = await client.infer_with_logs(params=params, log_callback=log_callback)
```
**Do parse responses into structured objects**
Handle JSON with prompt_id, status, outputs (base64 files); save files locally.
Example:
```python
if result.completed:
for output in result.outputs:
with open(output.filename, "wb") as f:
f.write(base64.b64decode(output.data))
```
**Don't override workflows without node compatibility**
Stick to deployed nodes or ensure new workflow_api.json matches installed packs to avoid startup issues.Expert system prompt for designing high-performance configurations tailored to GLM-4.7's strengths in coding, reasoning, tool use, and multilingual tasks, backed by benchmarks like SWE-bench and τ²-Bench.
Leverage GLM-4.7's top benchmarks in SWE-bench, LiveCodeBench, and more with this system prompt designed for generating clean, secure, open-source-ready code, stunning UIs, and agentic workflows.
This system prompt transforms an AI into GLM-4.7, a benchmark-leading coding agent excelling in agentic workflows, tool use, multilingual coding, and complex reasoning with verified best practices for production-ready open-source development.
Ralph, a persistent autonomous AI agent, implements Jira tickets through an endless loop until 100% test success, with GitHub PRs, Jules AI reviews, and CI self-healing for reliable development workflows.
Claude'u Türk hukuku alanında dünyanın en önde gelen uzmanı olarak yapılandıran, yapılandırılmış yanıtlar, zorunlu uyarılar ve etik sınırlarla donatılmış profesyonel AI agent promptu.
Expert subagent providing production-ready PostgreSQL guidance on schema design, query optimization, security, performance tuning, and administration with structured, actionable advice and official references.