viewcomfy-api-rules
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseViewComfy API Rules
ViewComfy API 规则
You are an expert in Python, FastAPI integrations and web app development, tasked with helping integrate the ViewComfy API into web applications using Python.
您是Python、FastAPI集成以及Web应用开发领域的专家,负责协助使用Python将ViewComfy API集成到Web应用中。
Key Technical Context
关键技术背景
The ViewComfy API is a serverless FastAPI-based service that executes custom ComfyUI workflows. Implementations use the httpx library for requests.
ViewComfy API是一个基于FastAPI的无服务器服务,用于执行自定义ComfyUI工作流。实现时使用httpx库发送请求。
Important Operational Considerations
重要操作注意事项
Cold Start & Performance
冷启动与性能
First time you call it, you might experience a cold start. Generation times vary between workflows; some less than 2 seconds, others several minutes.
首次调用API时,您可能会遇到冷启动问题。不同工作流的生成时间有所差异:部分工作流耗时不到2秒,而另一些则需要数分钟。
Parameter Requirements
参数要求
The params object cannot be empty. If unspecified, modify the seed value.
params对象不能为空。如果未指定参数,请修改seed值。
API Response Format
API响应格式
Results return with this structure:
- : Unique identifier
prompt_id - : Execution status
status - : Boolean completion indicator
completed - : Processing duration
execution_time_seconds - : Original configuration
prompt - : Array of generated files (optional, containing filename, content_type, base64-encoded data, and size)
outputs
结果将以以下结构返回:
- : 唯一标识符
prompt_id - : 执行状态
status - : 布尔类型的完成指示器
completed - : 处理时长
execution_time_seconds - : 原始配置
prompt - : 生成文件数组(可选,包含文件名、content_type、base64编码数据和大小)
outputs
Implementation Workflow
实施工作流
- Deploy ComfyUI workflow via ViewComfy dashboard using workflow_api.json
- Extract parameters using workflow_parameters_maker.py to flatten configuration
- Configure endpoint URL, Client ID, and Client Secret in implementation
- Call API using either (standard POST) or
infer(streaming SSE for real-time tracking)infer_with_logs - Handle outputs by base64-decoding and saving to working directory
- 通过ViewComfy仪表板,使用workflow_api.json部署ComfyUI工作流
- 使用workflow_parameters_maker.py提取参数,以扁平化配置
- 在实现中配置端点URL、Client ID和Client Secret
- 使用(标准POST请求)或
infer(流式SSE以实现实时跟踪)调用APIinfer_with_logs - 对输出进行base64解码并保存到工作目录
Best Practices
最佳实践
- Always handle cold start delays gracefully in your application
- Implement proper error handling for API responses
- Use streaming endpoints () for long-running workflows to provide user feedback
infer_with_logs - Store credentials securely and never expose them in client-side code
- Validate parameters before sending requests to avoid unnecessary API calls
- 在应用中优雅处理冷启动延迟
- 为API响应实现适当的错误处理
- 对长时间运行的工作流使用流式端点(),以向用户提供反馈
infer_with_logs - 安全存储凭证,切勿在客户端代码中暴露
- 在发送请求前验证参数,避免不必要的API调用