diff --git a/.github/scripts/snippets/gen-code-pages.ts b/.github/scripts/snippets/gen-code-pages.ts index 0609d230e..aebd6c759 100644 --- a/.github/scripts/snippets/gen-code-pages.ts +++ b/.github/scripts/snippets/gen-code-pages.ts @@ -336,11 +336,12 @@ function typescriptSnippet(model: string, example: Record, file ${reads ? `${reads}\n\n` : ""}// Reads COMFY_API_KEY from the environment. // The SDK automatically creates an idempotency key and reuses it for automatic retries. type Result = ${tsResultType(resultPath)}; -const { data } = await comfy.models.run("${model}", { +const result = await comfy.models.run("${model}", { ${body} }); +if (result.kind !== "json") throw new Error("expected a JSON result"); -console.log("${label}:", data${tsPath(resultPath)});`; +console.log("${label}:", result.data${tsPath(resultPath)});`; } function curlSnippet(model: string, example: Record, files: FileInput[]): string { diff --git a/development/comfy-router/models/black-forest-labs/flux-1-1-pro-ultra-image/code.mdx b/development/comfy-router/models/black-forest-labs/flux-1-1-pro-ultra-image/code.mdx index 06902dac0..1977cd80a 100644 --- a/development/comfy-router/models/black-forest-labs/flux-1-1-pro-ultra-image/code.mdx +++ b/development/comfy-router/models/black-forest-labs/flux-1-1-pro-ultra-image/code.mdx @@ -50,13 +50,14 @@ import { comfy } from "@comfyorg/sdk"; // Reads COMFY_API_KEY from the environment. // The SDK automatically creates an idempotency key and reuses it for automatic retries. type Result = { result: { sample: string } }; -const { data } = await comfy.models.run("bfl/flux-pro-1.1-ultra", { +const result = await comfy.models.run("bfl/flux-pro-1.1-ultra", { prompt: "a single red maple leaf on a plain white background, studio lighting", aspect_ratio: "16:9", raw: false, }); +if (result.kind !== "json") throw new Error("expected a JSON result"); -console.log("image:", data.result.sample); +console.log("image:", result.data.result.sample); ``` ```bash cURL @@ -333,13 +334,14 @@ import { comfy } from "@comfyorg/sdk"; // Reads COMFY_API_KEY from the environment. // The SDK automatically creates an idempotency key and reuses it for automatic retries. type Result = { result: { sample: string } }; -const { data } = await comfy.models.run("bfl/flux-pro-1.1", { +const result = await comfy.models.run("bfl/flux-pro-1.1", { prompt: "a single red maple leaf on a plain white background, studio lighting", width: 1024, height: 768, }); +if (result.kind !== "json") throw new Error("expected a JSON result"); -console.log("image:", data.result.sample); +console.log("image:", result.data.result.sample); ``` ```bash cURL diff --git a/development/comfy-router/models/black-forest-labs/flux-1-kontext/code.mdx b/development/comfy-router/models/black-forest-labs/flux-1-kontext/code.mdx index 32a73867b..23fa33160 100644 --- a/development/comfy-router/models/black-forest-labs/flux-1-kontext/code.mdx +++ b/development/comfy-router/models/black-forest-labs/flux-1-kontext/code.mdx @@ -58,13 +58,14 @@ const inputImage = (await readFile("input.jpg")).toString("base64"); // Reads COMFY_API_KEY from the environment. // The SDK automatically creates an idempotency key and reuses it for automatic retries. type Result = { result: { sample: string } }; -const { data } = await comfy.models.run("bfl/flux-kontext-pro", { +const result = await comfy.models.run("bfl/flux-kontext-pro", { prompt: "replace the background with a sunlit beach, keep the subject unchanged", input_image: inputImage, aspect_ratio: "1:1", }); +if (result.kind !== "json") throw new Error("expected a JSON result"); -console.log("image:", data.result.sample); +console.log("image:", result.data.result.sample); ``` ```bash cURL @@ -363,13 +364,14 @@ const inputImage = (await readFile("input.jpg")).toString("base64"); // Reads COMFY_API_KEY from the environment. // The SDK automatically creates an idempotency key and reuses it for automatic retries. type Result = { result: { sample: string } }; -const { data } = await comfy.models.run("bfl/flux-kontext-max", { +const result = await comfy.models.run("bfl/flux-kontext-max", { prompt: "replace the background with a sunlit beach, keep the subject unchanged", input_image: inputImage, aspect_ratio: "1:1", }); +if (result.kind !== "json") throw new Error("expected a JSON result"); -console.log("image:", data.result.sample); +console.log("image:", result.data.result.sample); ``` ```bash cURL diff --git a/development/comfy-router/models/black-forest-labs/flux-3-video/code.mdx b/development/comfy-router/models/black-forest-labs/flux-3-video/code.mdx index 7b6bdbfc6..40323462e 100644 --- a/development/comfy-router/models/black-forest-labs/flux-3-video/code.mdx +++ b/development/comfy-router/models/black-forest-labs/flux-3-video/code.mdx @@ -48,15 +48,16 @@ import { comfy } from "@comfyorg/sdk"; // Reads COMFY_API_KEY from the environment. // The SDK automatically creates an idempotency key and reuses it for automatic retries. type Result = { result: { sample: string } }; -const { data } = await comfy.models.run("bfl/flux-3-video", { +const result = await comfy.models.run("bfl/flux-3-video", { mode: "t2v", prompt: "a single red maple leaf falling onto still water, slow motion", duration: 5, aspect_ratio: "16:9", generate_audio: true, }); +if (result.kind !== "json") throw new Error("expected a JSON result"); -console.log("video:", data.result.sample); +console.log("video:", result.data.result.sample); ``` ```bash cURL diff --git a/development/comfy-router/models/black-forest-labs/flux-video-upscale/code.mdx b/development/comfy-router/models/black-forest-labs/flux-video-upscale/code.mdx index 1665ffaf6..5159bff76 100644 --- a/development/comfy-router/models/black-forest-labs/flux-video-upscale/code.mdx +++ b/development/comfy-router/models/black-forest-labs/flux-video-upscale/code.mdx @@ -46,13 +46,14 @@ import { comfy } from "@comfyorg/sdk"; // Reads COMFY_API_KEY from the environment. // The SDK automatically creates an idempotency key and reuses it for automatic retries. type Result = { result: { sample: string } }; -const { data } = await comfy.models.run("bfl/video-upscale-v1", { +const result = await comfy.models.run("bfl/video-upscale-v1", { input_video: "https://your-host.example/clip.mp4", upscale_factor: 2, creativity: 1, }); +if (result.kind !== "json") throw new Error("expected a JSON result"); -console.log("video:", data.result.sample); +console.log("video:", result.data.result.sample); ``` ```bash cURL diff --git a/development/comfy-router/models/google/gemini/code.mdx b/development/comfy-router/models/google/gemini/code.mdx index 6f5b6216c..2e63f8e71 100644 --- a/development/comfy-router/models/google/gemini/code.mdx +++ b/development/comfy-router/models/google/gemini/code.mdx @@ -61,7 +61,7 @@ import { comfy } from "@comfyorg/sdk"; // Reads COMFY_API_KEY from the environment. // The SDK automatically creates an idempotency key and reuses it for automatic retries. type Result = { candidates: { content: { parts: { text: string }[] } }[] }; -const { data } = await comfy.models.run("vertexai/gemini-3.1-pro-preview", { +const result = await comfy.models.run("vertexai/gemini-3.1-pro-preview", { contents: [ { role: "user", @@ -77,8 +77,9 @@ const { data } = await comfy.models.run("vertexai/gemini-3.1-pro-preview maxOutputTokens: 256, }, }); +if (result.kind !== "json") throw new Error("expected a JSON result"); -console.log("text:", data.candidates[0].content.parts[0].text); +console.log("text:", result.data.candidates[0].content.parts[0].text); ``` ```bash cURL @@ -234,7 +235,7 @@ import { comfy } from "@comfyorg/sdk"; // Reads COMFY_API_KEY from the environment. // The SDK automatically creates an idempotency key and reuses it for automatic retries. type Result = { candidates: { content: { parts: { text: string }[] } }[] }; -const { data } = await comfy.models.run("vertexai/gemini-3.5-flash", { +const result = await comfy.models.run("vertexai/gemini-3.5-flash", { contents: [ { role: "user", @@ -250,8 +251,9 @@ const { data } = await comfy.models.run("vertexai/gemini-3.5-flash", { maxOutputTokens: 256, }, }); +if (result.kind !== "json") throw new Error("expected a JSON result"); -console.log("text:", data.candidates[0].content.parts[0].text); +console.log("text:", result.data.candidates[0].content.parts[0].text); ``` ```bash cURL @@ -407,7 +409,7 @@ import { comfy } from "@comfyorg/sdk"; // Reads COMFY_API_KEY from the environment. // The SDK automatically creates an idempotency key and reuses it for automatic retries. type Result = { candidates: { content: { parts: { text: string }[] } }[] }; -const { data } = await comfy.models.run("vertexai/gemini-2.5-pro", { +const result = await comfy.models.run("vertexai/gemini-2.5-pro", { contents: [ { role: "user", @@ -423,8 +425,9 @@ const { data } = await comfy.models.run("vertexai/gemini-2.5-pro", { maxOutputTokens: 256, }, }); +if (result.kind !== "json") throw new Error("expected a JSON result"); -console.log("text:", data.candidates[0].content.parts[0].text); +console.log("text:", result.data.candidates[0].content.parts[0].text); ``` ```bash cURL @@ -580,7 +583,7 @@ import { comfy } from "@comfyorg/sdk"; // Reads COMFY_API_KEY from the environment. // The SDK automatically creates an idempotency key and reuses it for automatic retries. type Result = { candidates: { content: { parts: { text: string }[] } }[] }; -const { data } = await comfy.models.run("vertexai/gemini-2.5-flash", { +const result = await comfy.models.run("vertexai/gemini-2.5-flash", { contents: [ { role: "user", @@ -596,8 +599,9 @@ const { data } = await comfy.models.run("vertexai/gemini-2.5-flash", { maxOutputTokens: 256, }, }); +if (result.kind !== "json") throw new Error("expected a JSON result"); -console.log("text:", data.candidates[0].content.parts[0].text); +console.log("text:", result.data.candidates[0].content.parts[0].text); ``` ```bash cURL diff --git a/development/comfy-router/models/google/nano-banana-2-lite/code.mdx b/development/comfy-router/models/google/nano-banana-2-lite/code.mdx index 7bbf23a75..ca9505e6c 100644 --- a/development/comfy-router/models/google/nano-banana-2-lite/code.mdx +++ b/development/comfy-router/models/google/nano-banana-2-lite/code.mdx @@ -59,7 +59,7 @@ import { comfy } from "@comfyorg/sdk"; // Reads COMFY_API_KEY from the environment. // The SDK automatically creates an idempotency key and reuses it for automatic retries. type Result = { candidates: { content: { parts: { inlineData: { data: string } }[] } }[] }; -const { data } = await comfy.models.run("vertexai/gemini-3.1-flash-lite-image", { +const result = await comfy.models.run("vertexai/gemini-3.1-flash-lite-image", { contents: [ { role: "user", @@ -77,8 +77,9 @@ const { data } = await comfy.models.run("vertexai/gemini-3.1-flash-lite- }, }, }); +if (result.kind !== "json") throw new Error("expected a JSON result"); -console.log("image (base64):", data.candidates[0].content.parts[0].inlineData.data); +console.log("image (base64):", result.data.candidates[0].content.parts[0].inlineData.data); ``` ```bash cURL diff --git a/development/comfy-router/models/google/nano-banana-2/code.mdx b/development/comfy-router/models/google/nano-banana-2/code.mdx index f67283492..fd259d630 100644 --- a/development/comfy-router/models/google/nano-banana-2/code.mdx +++ b/development/comfy-router/models/google/nano-banana-2/code.mdx @@ -59,7 +59,7 @@ import { comfy } from "@comfyorg/sdk"; // Reads COMFY_API_KEY from the environment. // The SDK automatically creates an idempotency key and reuses it for automatic retries. type Result = { candidates: { content: { parts: { inlineData: { data: string } }[] } }[] }; -const { data } = await comfy.models.run("vertexai/gemini-3.1-flash-image", { +const result = await comfy.models.run("vertexai/gemini-3.1-flash-image", { contents: [ { role: "user", @@ -77,8 +77,9 @@ const { data } = await comfy.models.run("vertexai/gemini-3.1-flash-image }, }, }); +if (result.kind !== "json") throw new Error("expected a JSON result"); -console.log("image (base64):", data.candidates[0].content.parts[0].inlineData.data); +console.log("image (base64):", result.data.candidates[0].content.parts[0].inlineData.data); ``` ```bash cURL diff --git a/development/comfy-router/models/google/nano-banana-pro/code.mdx b/development/comfy-router/models/google/nano-banana-pro/code.mdx index d9148897f..37b4a5efb 100644 --- a/development/comfy-router/models/google/nano-banana-pro/code.mdx +++ b/development/comfy-router/models/google/nano-banana-pro/code.mdx @@ -59,7 +59,7 @@ import { comfy } from "@comfyorg/sdk"; // Reads COMFY_API_KEY from the environment. // The SDK automatically creates an idempotency key and reuses it for automatic retries. type Result = { candidates: { content: { parts: { inlineData: { data: string } }[] } }[] }; -const { data } = await comfy.models.run("vertexai/gemini-3-pro-image", { +const result = await comfy.models.run("vertexai/gemini-3-pro-image", { contents: [ { role: "user", @@ -77,8 +77,9 @@ const { data } = await comfy.models.run("vertexai/gemini-3-pro-image", { }, }, }); +if (result.kind !== "json") throw new Error("expected a JSON result"); -console.log("image (base64):", data.candidates[0].content.parts[0].inlineData.data); +console.log("image (base64):", result.data.candidates[0].content.parts[0].inlineData.data); ``` ```bash cURL diff --git a/development/comfy-router/models/ideogram/ideogram-v4/code.mdx b/development/comfy-router/models/ideogram/ideogram-v4/code.mdx index 9a6f05a52..4c99120cc 100644 --- a/development/comfy-router/models/ideogram/ideogram-v4/code.mdx +++ b/development/comfy-router/models/ideogram/ideogram-v4/code.mdx @@ -46,13 +46,14 @@ import { comfy } from "@comfyorg/sdk"; // Reads COMFY_API_KEY from the environment. // The SDK automatically creates an idempotency key and reuses it for automatic retries. type Result = { data: { url: string }[] }; -const { data } = await comfy.models.run("ideogram/ideogram-v4", { +const result = await comfy.models.run("ideogram/ideogram-v4", { text_prompt: "a single red maple leaf on a plain white background, studio lighting", resolution: "1024x1024", rendering_speed: "DEFAULT", }); +if (result.kind !== "json") throw new Error("expected a JSON result"); -console.log("image:", data.data[0].url); +console.log("image:", result.data.data[0].url); ``` ```bash cURL diff --git a/development/comfy-router/models/wan/happyhorse-1-0-i2v/code.mdx b/development/comfy-router/models/wan/happyhorse-1-0-i2v/code.mdx index b1592e983..6602f314d 100644 --- a/development/comfy-router/models/wan/happyhorse-1-0-i2v/code.mdx +++ b/development/comfy-router/models/wan/happyhorse-1-0-i2v/code.mdx @@ -51,7 +51,7 @@ import { comfy } from "@comfyorg/sdk"; // Reads COMFY_API_KEY from the environment. // The SDK automatically creates an idempotency key and reuses it for automatic retries. type Result = { output: { video_url: string } }; -const { data } = await comfy.models.run("wan/happyhorse-1.0-i2v", { +const result = await comfy.models.run("wan/happyhorse-1.0-i2v", { input: { prompt: "the robot lowers its raised arm and steps toward the camera, the flat orange backdrop holds steady", img_url: "https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/input/pink_robot_front.png", @@ -61,8 +61,9 @@ const { data } = await comfy.models.run("wan/happyhorse-1.0-i2v", { duration: 5, }, }); +if (result.kind !== "json") throw new Error("expected a JSON result"); -console.log("video:", data.output.video_url); +console.log("video:", result.data.output.video_url); ``` ```bash cURL diff --git a/development/comfy-router/models/wan/happyhorse-1-0-r2v/code.mdx b/development/comfy-router/models/wan/happyhorse-1-0-r2v/code.mdx index 50d891bbf..04cd133b4 100644 --- a/development/comfy-router/models/wan/happyhorse-1-0-r2v/code.mdx +++ b/development/comfy-router/models/wan/happyhorse-1-0-r2v/code.mdx @@ -56,7 +56,7 @@ import { comfy } from "@comfyorg/sdk"; // Reads COMFY_API_KEY from the environment. // The SDK automatically creates an idempotency key and reuses it for automatic retries. type Result = { output: { video_url: string } }; -const { data } = await comfy.models.run("wan/happyhorse-1.0-r2v", { +const result = await comfy.models.run("wan/happyhorse-1.0-r2v", { input: { prompt: "character1 walks in from the left, turns to the camera and waves, plain orange backdrop", media: [ @@ -71,8 +71,9 @@ const { data } = await comfy.models.run("wan/happyhorse-1.0-r2v", { duration: 5, }, }); +if (result.kind !== "json") throw new Error("expected a JSON result"); -console.log("video:", data.output.video_url); +console.log("video:", result.data.output.video_url); ``` ```bash cURL diff --git a/development/comfy-router/models/wan/happyhorse-1-0-t2v/code.mdx b/development/comfy-router/models/wan/happyhorse-1-0-t2v/code.mdx index 8f8bf3ea9..a44a14b76 100644 --- a/development/comfy-router/models/wan/happyhorse-1-0-t2v/code.mdx +++ b/development/comfy-router/models/wan/happyhorse-1-0-t2v/code.mdx @@ -50,7 +50,7 @@ import { comfy } from "@comfyorg/sdk"; // Reads COMFY_API_KEY from the environment. // The SDK automatically creates an idempotency key and reuses it for automatic retries. type Result = { output: { video_url: string } }; -const { data } = await comfy.models.run("wan/happyhorse-1.0-t2v", { +const result = await comfy.models.run("wan/happyhorse-1.0-t2v", { input: { prompt: "a single red maple leaf falling onto still water, slow motion, shallow depth of field", }, @@ -59,8 +59,9 @@ const { data } = await comfy.models.run("wan/happyhorse-1.0-t2v", { duration: 5, }, }); +if (result.kind !== "json") throw new Error("expected a JSON result"); -console.log("video:", data.output.video_url); +console.log("video:", result.data.output.video_url); ``` ```bash cURL diff --git a/development/comfy-router/models/wan/happyhorse-1-0-video-edit/code.mdx b/development/comfy-router/models/wan/happyhorse-1-0-video-edit/code.mdx index c45a51b6e..de1760ad1 100644 --- a/development/comfy-router/models/wan/happyhorse-1-0-video-edit/code.mdx +++ b/development/comfy-router/models/wan/happyhorse-1-0-video-edit/code.mdx @@ -55,7 +55,7 @@ import { comfy } from "@comfyorg/sdk"; // Reads COMFY_API_KEY from the environment. // The SDK automatically creates an idempotency key and reuses it for automatic retries. type Result = { output: { video_url: string } }; -const { data } = await comfy.models.run("wan/happyhorse-1.0-video-edit", { +const result = await comfy.models.run("wan/happyhorse-1.0-video-edit", { input: { prompt: "restyle the clip as a hand-drawn ink sketch, keep the dancer's movement unchanged", media: [ @@ -69,8 +69,9 @@ const { data } = await comfy.models.run("wan/happyhorse-1.0-video-edit", resolution: "720P", }, }); +if (result.kind !== "json") throw new Error("expected a JSON result"); -console.log("video:", data.output.video_url); +console.log("video:", result.data.output.video_url); ``` ```bash cURL diff --git a/development/comfy-router/models/wan/happyhorse-1-1-i2v/code.mdx b/development/comfy-router/models/wan/happyhorse-1-1-i2v/code.mdx index b661a912a..6cc88e1d0 100644 --- a/development/comfy-router/models/wan/happyhorse-1-1-i2v/code.mdx +++ b/development/comfy-router/models/wan/happyhorse-1-1-i2v/code.mdx @@ -51,7 +51,7 @@ import { comfy } from "@comfyorg/sdk"; // Reads COMFY_API_KEY from the environment. // The SDK automatically creates an idempotency key and reuses it for automatic retries. type Result = { output: { video_url: string } }; -const { data } = await comfy.models.run("wan/happyhorse-1.1-i2v", { +const result = await comfy.models.run("wan/happyhorse-1.1-i2v", { input: { prompt: "the robot lowers its raised arm and steps toward the camera, the flat orange backdrop holds steady", img_url: "https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/input/pink_robot_front.png", @@ -61,8 +61,9 @@ const { data } = await comfy.models.run("wan/happyhorse-1.1-i2v", { duration: 5, }, }); +if (result.kind !== "json") throw new Error("expected a JSON result"); -console.log("video:", data.output.video_url); +console.log("video:", result.data.output.video_url); ``` ```bash cURL diff --git a/development/comfy-router/models/wan/happyhorse-1-1-r2v/code.mdx b/development/comfy-router/models/wan/happyhorse-1-1-r2v/code.mdx index 8c31592f4..cae6e2a18 100644 --- a/development/comfy-router/models/wan/happyhorse-1-1-r2v/code.mdx +++ b/development/comfy-router/models/wan/happyhorse-1-1-r2v/code.mdx @@ -56,7 +56,7 @@ import { comfy } from "@comfyorg/sdk"; // Reads COMFY_API_KEY from the environment. // The SDK automatically creates an idempotency key and reuses it for automatic retries. type Result = { output: { video_url: string } }; -const { data } = await comfy.models.run("wan/happyhorse-1.1-r2v", { +const result = await comfy.models.run("wan/happyhorse-1.1-r2v", { input: { prompt: "character1 walks in from the left, turns to the camera and waves, plain orange backdrop", media: [ @@ -71,8 +71,9 @@ const { data } = await comfy.models.run("wan/happyhorse-1.1-r2v", { duration: 5, }, }); +if (result.kind !== "json") throw new Error("expected a JSON result"); -console.log("video:", data.output.video_url); +console.log("video:", result.data.output.video_url); ``` ```bash cURL diff --git a/development/comfy-router/models/wan/happyhorse-1-1-t2v/code.mdx b/development/comfy-router/models/wan/happyhorse-1-1-t2v/code.mdx index 4bcc37983..4d6a7bb14 100644 --- a/development/comfy-router/models/wan/happyhorse-1-1-t2v/code.mdx +++ b/development/comfy-router/models/wan/happyhorse-1-1-t2v/code.mdx @@ -50,7 +50,7 @@ import { comfy } from "@comfyorg/sdk"; // Reads COMFY_API_KEY from the environment. // The SDK automatically creates an idempotency key and reuses it for automatic retries. type Result = { output: { video_url: string } }; -const { data } = await comfy.models.run("wan/happyhorse-1.1-t2v", { +const result = await comfy.models.run("wan/happyhorse-1.1-t2v", { input: { prompt: "a single red maple leaf falling onto still water, slow motion, shallow depth of field", }, @@ -59,8 +59,9 @@ const { data } = await comfy.models.run("wan/happyhorse-1.1-t2v", { duration: 5, }, }); +if (result.kind !== "json") throw new Error("expected a JSON result"); -console.log("video:", data.output.video_url); +console.log("video:", result.data.output.video_url); ``` ```bash cURL diff --git a/development/comfy-router/models/wan/wan2-5-i2v-preview/code.mdx b/development/comfy-router/models/wan/wan2-5-i2v-preview/code.mdx index 3c0e2dd04..cc0d0cce2 100644 --- a/development/comfy-router/models/wan/wan2-5-i2v-preview/code.mdx +++ b/development/comfy-router/models/wan/wan2-5-i2v-preview/code.mdx @@ -51,7 +51,7 @@ import { comfy } from "@comfyorg/sdk"; // Reads COMFY_API_KEY from the environment. // The SDK automatically creates an idempotency key and reuses it for automatic retries. type Result = { output: { video_url: string } }; -const { data } = await comfy.models.run("wan/wan2.5-i2v-preview", { +const result = await comfy.models.run("wan/wan2.5-i2v-preview", { input: { prompt: "the robot lowers its raised arm and steps toward the camera, the flat orange backdrop holds steady", img_url: "https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/input/pink_robot_front.png", @@ -61,8 +61,9 @@ const { data } = await comfy.models.run("wan/wan2.5-i2v-preview", { duration: 5, }, }); +if (result.kind !== "json") throw new Error("expected a JSON result"); -console.log("video:", data.output.video_url); +console.log("video:", result.data.output.video_url); ``` ```bash cURL diff --git a/development/comfy-router/models/wan/wan2-5-t2v-preview/code.mdx b/development/comfy-router/models/wan/wan2-5-t2v-preview/code.mdx index 125cff394..8b7569a83 100644 --- a/development/comfy-router/models/wan/wan2-5-t2v-preview/code.mdx +++ b/development/comfy-router/models/wan/wan2-5-t2v-preview/code.mdx @@ -50,7 +50,7 @@ import { comfy } from "@comfyorg/sdk"; // Reads COMFY_API_KEY from the environment. // The SDK automatically creates an idempotency key and reuses it for automatic retries. type Result = { output: { video_url: string } }; -const { data } = await comfy.models.run("wan/wan2.5-t2v-preview", { +const result = await comfy.models.run("wan/wan2.5-t2v-preview", { input: { prompt: "a single red maple leaf falling onto still water, slow motion, shallow depth of field", }, @@ -59,8 +59,9 @@ const { data } = await comfy.models.run("wan/wan2.5-t2v-preview", { duration: 5, }, }); +if (result.kind !== "json") throw new Error("expected a JSON result"); -console.log("video:", data.output.video_url); +console.log("video:", result.data.output.video_url); ``` ```bash cURL diff --git a/development/comfy-router/models/wan/wan2-6-i2v/code.mdx b/development/comfy-router/models/wan/wan2-6-i2v/code.mdx index e424df241..87e2f8435 100644 --- a/development/comfy-router/models/wan/wan2-6-i2v/code.mdx +++ b/development/comfy-router/models/wan/wan2-6-i2v/code.mdx @@ -51,7 +51,7 @@ import { comfy } from "@comfyorg/sdk"; // Reads COMFY_API_KEY from the environment. // The SDK automatically creates an idempotency key and reuses it for automatic retries. type Result = { output: { video_url: string } }; -const { data } = await comfy.models.run("wan/wan2.6-i2v", { +const result = await comfy.models.run("wan/wan2.6-i2v", { input: { prompt: "the robot lowers its raised arm and steps toward the camera, the flat orange backdrop holds steady", img_url: "https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/input/pink_robot_front.png", @@ -61,8 +61,9 @@ const { data } = await comfy.models.run("wan/wan2.6-i2v", { duration: 5, }, }); +if (result.kind !== "json") throw new Error("expected a JSON result"); -console.log("video:", data.output.video_url); +console.log("video:", result.data.output.video_url); ``` ```bash cURL diff --git a/development/comfy-router/models/wan/wan2-6-r2v/code.mdx b/development/comfy-router/models/wan/wan2-6-r2v/code.mdx index 55a681769..eb19d3086 100644 --- a/development/comfy-router/models/wan/wan2-6-r2v/code.mdx +++ b/development/comfy-router/models/wan/wan2-6-r2v/code.mdx @@ -51,7 +51,7 @@ import { comfy } from "@comfyorg/sdk"; // Reads COMFY_API_KEY from the environment. // The SDK automatically creates an idempotency key and reuses it for automatic retries. type Result = { output: { video_url: string } }; -const { data } = await comfy.models.run("wan/wan2.6-r2v", { +const result = await comfy.models.run("wan/wan2.6-r2v", { input: { prompt: "character1 walks in from the left, turns to the camera and waves, plain orange backdrop", reference_video_urls: ["https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/input/street_dancer.mp4"], @@ -61,8 +61,9 @@ const { data } = await comfy.models.run("wan/wan2.6-r2v", { duration: 5, }, }); +if (result.kind !== "json") throw new Error("expected a JSON result"); -console.log("video:", data.output.video_url); +console.log("video:", result.data.output.video_url); ``` ```bash cURL diff --git a/development/comfy-router/models/wan/wan2-6-t2v/code.mdx b/development/comfy-router/models/wan/wan2-6-t2v/code.mdx index 793267f49..4b748bd3c 100644 --- a/development/comfy-router/models/wan/wan2-6-t2v/code.mdx +++ b/development/comfy-router/models/wan/wan2-6-t2v/code.mdx @@ -50,7 +50,7 @@ import { comfy } from "@comfyorg/sdk"; // Reads COMFY_API_KEY from the environment. // The SDK automatically creates an idempotency key and reuses it for automatic retries. type Result = { output: { video_url: string } }; -const { data } = await comfy.models.run("wan/wan2.6-t2v", { +const result = await comfy.models.run("wan/wan2.6-t2v", { input: { prompt: "a single red maple leaf falling onto still water, slow motion, shallow depth of field", }, @@ -59,8 +59,9 @@ const { data } = await comfy.models.run("wan/wan2.6-t2v", { duration: 5, }, }); +if (result.kind !== "json") throw new Error("expected a JSON result"); -console.log("video:", data.output.video_url); +console.log("video:", result.data.output.video_url); ``` ```bash cURL diff --git a/development/comfy-router/models/wan/wan2-7-i2v/code.mdx b/development/comfy-router/models/wan/wan2-7-i2v/code.mdx index b2a575a0f..ab3a72cd1 100644 --- a/development/comfy-router/models/wan/wan2-7-i2v/code.mdx +++ b/development/comfy-router/models/wan/wan2-7-i2v/code.mdx @@ -56,7 +56,7 @@ import { comfy } from "@comfyorg/sdk"; // Reads COMFY_API_KEY from the environment. // The SDK automatically creates an idempotency key and reuses it for automatic retries. type Result = { output: { video_url: string } }; -const { data } = await comfy.models.run("wan/wan2.7-i2v", { +const result = await comfy.models.run("wan/wan2.7-i2v", { input: { prompt: "the robot lowers its raised arm and steps toward the camera, the flat orange backdrop holds steady", media: [ @@ -71,8 +71,9 @@ const { data } = await comfy.models.run("wan/wan2.7-i2v", { duration: 5, }, }); +if (result.kind !== "json") throw new Error("expected a JSON result"); -console.log("video:", data.output.video_url); +console.log("video:", result.data.output.video_url); ``` ```bash cURL diff --git a/development/comfy-router/models/wan/wan2-7-r2v/code.mdx b/development/comfy-router/models/wan/wan2-7-r2v/code.mdx index 4ca00f256..f53190942 100644 --- a/development/comfy-router/models/wan/wan2-7-r2v/code.mdx +++ b/development/comfy-router/models/wan/wan2-7-r2v/code.mdx @@ -56,7 +56,7 @@ import { comfy } from "@comfyorg/sdk"; // Reads COMFY_API_KEY from the environment. // The SDK automatically creates an idempotency key and reuses it for automatic retries. type Result = { output: { video_url: string } }; -const { data } = await comfy.models.run("wan/wan2.7-r2v", { +const result = await comfy.models.run("wan/wan2.7-r2v", { input: { prompt: "character1 walks in from the left, turns to the camera and waves, plain orange backdrop", media: [ @@ -71,8 +71,9 @@ const { data } = await comfy.models.run("wan/wan2.7-r2v", { duration: 5, }, }); +if (result.kind !== "json") throw new Error("expected a JSON result"); -console.log("video:", data.output.video_url); +console.log("video:", result.data.output.video_url); ``` ```bash cURL diff --git a/development/comfy-router/models/wan/wan2-7-t2v/code.mdx b/development/comfy-router/models/wan/wan2-7-t2v/code.mdx index 53d4a0f10..c9125cb2a 100644 --- a/development/comfy-router/models/wan/wan2-7-t2v/code.mdx +++ b/development/comfy-router/models/wan/wan2-7-t2v/code.mdx @@ -50,7 +50,7 @@ import { comfy } from "@comfyorg/sdk"; // Reads COMFY_API_KEY from the environment. // The SDK automatically creates an idempotency key and reuses it for automatic retries. type Result = { output: { video_url: string } }; -const { data } = await comfy.models.run("wan/wan2.7-t2v", { +const result = await comfy.models.run("wan/wan2.7-t2v", { input: { prompt: "a single red maple leaf falling onto still water, slow motion, shallow depth of field", }, @@ -59,8 +59,9 @@ const { data } = await comfy.models.run("wan/wan2.7-t2v", { duration: 5, }, }); +if (result.kind !== "json") throw new Error("expected a JSON result"); -console.log("video:", data.output.video_url); +console.log("video:", result.data.output.video_url); ``` ```bash cURL diff --git a/development/comfy-router/models/wan/wan2-7-videoedit/code.mdx b/development/comfy-router/models/wan/wan2-7-videoedit/code.mdx index 57efd9344..0b292604e 100644 --- a/development/comfy-router/models/wan/wan2-7-videoedit/code.mdx +++ b/development/comfy-router/models/wan/wan2-7-videoedit/code.mdx @@ -56,7 +56,7 @@ import { comfy } from "@comfyorg/sdk"; // Reads COMFY_API_KEY from the environment. // The SDK automatically creates an idempotency key and reuses it for automatic retries. type Result = { output: { video_url: string } }; -const { data } = await comfy.models.run("wan/wan2.7-videoedit", { +const result = await comfy.models.run("wan/wan2.7-videoedit", { input: { prompt: "restyle the clip as a hand-drawn ink sketch, keep the dancer's movement unchanged", media: [ @@ -71,8 +71,9 @@ const { data } = await comfy.models.run("wan/wan2.7-videoedit", { audio_setting: "origin", }, }); +if (result.kind !== "json") throw new Error("expected a JSON result"); -console.log("video:", data.output.video_url); +console.log("video:", result.data.output.video_url); ``` ```bash cURL diff --git a/development/comfy-router/models/wan/wan3-0-video-prime/code.mdx b/development/comfy-router/models/wan/wan3-0-video-prime/code.mdx index 801127cba..c6ad2bb7b 100644 --- a/development/comfy-router/models/wan/wan3-0-video-prime/code.mdx +++ b/development/comfy-router/models/wan/wan3-0-video-prime/code.mdx @@ -50,7 +50,7 @@ import { comfy } from "@comfyorg/sdk"; // Reads COMFY_API_KEY from the environment. // The SDK automatically creates an idempotency key and reuses it for automatic retries. type Result = { output: { video_url: string } }; -const { data } = await comfy.models.run("wan/wan3.0-video-prime", { +const result = await comfy.models.run("wan/wan3.0-video-prime", { input: { prompt: "a single red maple leaf falling onto still water, slow motion, shallow depth of field", }, @@ -59,8 +59,9 @@ const { data } = await comfy.models.run("wan/wan3.0-video-prime", { duration: 5, }, }); +if (result.kind !== "json") throw new Error("expected a JSON result"); -console.log("video:", data.output.video_url); +console.log("video:", result.data.output.video_url); ``` ```bash cURL diff --git a/development/comfy-router/models/wan/wan3-0-video/code.mdx b/development/comfy-router/models/wan/wan3-0-video/code.mdx index d76a2103d..f9024772f 100644 --- a/development/comfy-router/models/wan/wan3-0-video/code.mdx +++ b/development/comfy-router/models/wan/wan3-0-video/code.mdx @@ -56,7 +56,7 @@ import { comfy } from "@comfyorg/sdk"; // Reads COMFY_API_KEY from the environment. // The SDK automatically creates an idempotency key and reuses it for automatic retries. type Result = { output: { video_url: string } }; -const { data } = await comfy.models.run("wan/wan3.0-video", { +const result = await comfy.models.run("wan/wan3.0-video", { input: { prompt: "the robot lowers its raised arm and steps toward the camera, the flat orange backdrop holds steady", media: [ @@ -71,8 +71,9 @@ const { data } = await comfy.models.run("wan/wan3.0-video", { duration: 5, }, }); +if (result.kind !== "json") throw new Error("expected a JSON result"); -console.log("video:", data.output.video_url); +console.log("video:", result.data.output.video_url); ``` ```bash cURL diff --git a/development/comfy-router/quickstart.mdx b/development/comfy-router/quickstart.mdx index 6e6b812d9..ef77629ca 100644 --- a/development/comfy-router/quickstart.mdx +++ b/development/comfy-router/quickstart.mdx @@ -66,7 +66,7 @@ Comfy Router lets you call partner models through `https://api.comfy.org` with o ```typescript TypeScript // Node.js 22+ - // Install: npm install @comfyorg/sdk@^0.1.9 --save-dev tsx + // Install: npm install @comfyorg/sdk@^0.3.0 --save-dev tsx // Save as quickstart.mts, then run: npx tsx quickstart.mts import { comfy } from "@comfyorg/sdk"; @@ -76,13 +76,15 @@ Comfy Router lets you call partner models through `https://api.comfy.org` with o const idempotencyKey = process.env.COMFY_REQUEST_KEY; if (!idempotencyKey) throw new Error("Set COMFY_REQUEST_KEY first."); - const { data } = await comfy.models.run( + const result = await comfy.models.run( "bfl/flux-2-pro", { prompt: "a red teapot on a windowsill, morning light" }, { idempotencyKey, timeoutMs: 660_000 }, ); + // Some models answer with the generated file itself rather than JSON. + if (result.kind !== "json") throw new Error("expected a JSON result"); - console.log("image:", data.result.sample); + console.log("image:", result.data.result.sample); ```