Files
imeepos 08b981c31f feat: add uni-comfyui-sdk - Rust SDK for ComfyUI API
- Complete Rust SDK implementation based on OpenAPI specification
- All 23 endpoints implemented with type-safe interfaces
- Comprehensive error handling and async support
- Full documentation and examples included
- Client renamed to UniComfyUIClient for clear identification
2025-08-15 15:31:33 +08:00

57 lines
1.8 KiB
Rust

use std::collections::HashMap;
use uni_comfyui_sdk::{UniComfyUIClient, Result, ServerRegistrationRequest};
#[tokio::main]
async fn main() -> Result<()> {
// Create a new client
let client = UniComfyUIClient::new("http://192.168.0.148:18000")?;
// Get system metrics
println!("Getting system metrics...");
let metrics = client.get_metrics().await?;
println!("Metrics: {:#?}", metrics);
// Get all workflows
println!("\nGetting all workflows...");
let workflows = client.get_all_workflows().await?;
println!("Found {} workflows", workflows.len());
// Get servers status
println!("\nGetting servers status...");
let servers = client.get_servers_status().await?;
println!("Found {} servers", servers.len());
// Health check
println!("\nPerforming health check...");
let health = client.health_check().await?;
println!("Health status: {:#?}", health);
// Example: Register a new server
println!("\nRegistering a new server...");
let registration_request = ServerRegistrationRequest {
name: "test-server".to_string(),
http_url: "http://192.168.0.148:8188".to_string(),
ws_url: "ws://192.168.0.148:8188".to_string(),
};
match client.register_server(registration_request).await {
Ok(response) => println!("Server registered: {:#?}", response),
Err(e) => println!("Failed to register server: {}", e),
}
// Example: Run a workflow
println!("\nRunning a workflow...");
let mut workflow_data = HashMap::new();
workflow_data.insert("input".to_string(), serde_json::json!("test input"));
match client
.run_workflow("test_workflow", None, workflow_data)
.await
{
Ok(response) => println!("Workflow started: {:#?}", response),
Err(e) => println!("Failed to start workflow: {}", e),
}
Ok(())
}