import { DeploymentRow, SharePageDeploymentRow } from "./DeploymentRow"; import { CodeBlock } from "@/components/CodeBlock"; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger, } from "@/components/ui/dialog"; import { ScrollArea } from "@/components/ui/scroll-area"; import { TableRow } from "@/components/ui/table"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { getInputsFromWorkflow } from "@/lib/getInputsFromWorkflow"; import type { findAllDeployments } from "@/server/findAllRuns"; const curlTemplate = ` curl --request POST \ --url \ --header "Content-Type: application/json" \ --data "{ "deployment_id": "" }" `; const curlTemplate_checkStatus = ` curl --request GET \ --url "/api/run?run_id=xxx" \ --header "Content-Type: application/json" `; const jsTemplate = ` const { run_id } = await fetch("", { method: "POST", headers: { "Content-Type": "application/json", "Authorization": "Bearer " + process.env.COMFY_DEPLOY_API_KEY, }, body: JSON.stringify({ deployment_id: "", inputs: {} }), }).then(response => response.json()) `; const jsTemplate_checkStatus = ` const run_id = ""; const output = fetch("?run_id=" + run_id, { method: "GET", headers: { "Content-Type": "application/json", "Authorization": "Bearer " + process.env.COMFY_DEPLOY_API_KEY, }, }).then(response => response.json()) `; const jsClientSetupTemplate = ` const client = new ComfyDeployClient({ apiBase: "", apiToken: process.env.COMFY_DEPLOY_API_KEY!, }); `; const jsClientSetupTemplateHostedVersion = ` const client = new ComfyDeployClient({ apiToken: process.env.COMFY_DEPLOY_API_KEY!, }); `; const jsClientCreateRunTemplate = ` const { run_id } = await client.run("", { inputs: {} }); `; const jsClientCreateRunNoInputsTemplate = ` const { run_id } = await client.run(""); `; const clientTemplate_checkStatus = ` const run = await client.getRun(run_id); `; export function DeploymentDisplay({ deployment, domain, }: { deployment: Awaited>[0]; domain: string; }) { const workflowInput = getInputsFromWorkflow(deployment.version); if (deployment.environment == "public-share") { return ; } return ( {deployment.environment} Deployment Code for your deployment client Server Client NodeJS Fetch CURL
Copy and paste the ComfyDeployClient form  here
Create a run via deployment id 0 ? jsClientCreateRunTemplate : jsClientCreateRunNoInputsTemplate, deployment, domain, workflowInput )} /> Check the status of the run, and retrieve the outputs
Trigger the workflow Check the status of the run, and retrieve the outputs
); } function formatCode( codeTemplate: string, deployment: Awaited>[0], domain: string, inputs?: ReturnType, inputsTabs?: number ) { if (inputs && inputs.length > 0) { codeTemplate = codeTemplate.replace( "inputs: {}", `inputs: ${JSON.stringify( Object.fromEntries( inputs.map((x) => { return [x?.input_id, ""]; }) ), null, 2 ) .split("\n") .map((line, index) => (index === 0 ? line : ` ${line}`)) // Add two spaces indentation except for the first line .join("\n")}` ); } else { codeTemplate = codeTemplate.replace( ` inputs: {}`, "" ); } return codeTemplate .replace("", `${domain ?? "http://localhost:3000"}/api/run`) .replace("", deployment.id) .replace("", domain ?? "http://localhost:3000"); }