Closed smilebear2010 closed 7 months ago
You will need to call the endpoint to queue for the API, docs is coming on the way!
but here's a js client i have made for server side previously
Comfy Deploy Client
```ts
import { z } from "zod";
const runTypes = z.object({
run_id: z.string(),
});
const runOutputTypes = z.object({
id: z.string(),
status: z.string(),
outputs: z.array(
z.object({
data: z.any(),
})
),
});
export class ComfyDeployClient {
apiBase: string = "https://www.comfydeploy.com/api";
apiToken: string;
constructor({ apiBase, apiToken }: { apiBase?: string; apiToken: string }) {
if (apiBase)
this.apiBase = `${apiBase}/api`;
this.apiToken = apiToken;
}
async run({
deployment_id,
inputs,
}: {
deployment_id: string;
inputs?: Record
Calling run API
const result = await client.run({
deployment_id: "<deployment_id>",
inputs: {
input_text: "some input if have",
},
});
Example run response object
{
"run_id": "acb550a9-5b4f-4758-a484-50d5245d394f"
}
Checking the API Outputs
const outputs = await client.getRun(result.run_id);
Example run outputs object
{
"id": "acb550a9-5b4f-4758-a484-50d5245d394f",
"workflow_version_id": "6307f76b-bb76-4583-9b3c-d7979adb2828",
"workflow_inputs": {
"input_text": "(a beautiful alien relaxing by the sea:1.2) (final professional masterpiece highly overflowing detailed:1.1), (room bokeh, warm soft lighting:1.1)"
},
"workflow_id": "31e4e07c-5478-487a-b507-82ea630dcbb0",
"machine_id": "04f199fe-51ec-43c7-81da-ecb1d16db3fe",
"origin": "api",
"status": "success",
"ended_at": "2023-12-30T16:00:54.356Z",
"created_at": "2023-12-30T15:59:15.993Z",
"outputs": [
{
"data": {
"images": [
{
"type": "temp",
"filename": "ComfyUI_temp_fnzzp_00001_.png",
"subfolder": "",
"url": "https://storage.comfydeploy.com/outputs/runs/acb550a9-5b4f-4758-a484-50d5245d394f/ComfyUI_temp_fnzzp_00001_.png"
}
]
}
}
]
}
.env.local
COMFY_DEPLOY_AUTH=<YOUR_API_KEY>
I can't open this webpage 'https://www.comfydeploy.com/api/run' - it's showing 'Invalid or expired token'."