run_workflow
Execute AI image generation workflows using Fal.ai models like SDXL to process inputs and stream results for creative projects.
Instructions
Run a Fal.ai workflow (e.g., sdxl-sticker pipeline)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input | Yes | Input parameters for the workflow | |
| stream | No | Whether to stream workflow events | |
| workflow_id | Yes | The workflow ID |
Implementation Reference
- src/index.ts:324-363 (handler)Handler logic for the 'run_workflow' tool. Parses arguments using RunWorkflowSchema, then either streams or subscribes to the specified Fal.ai workflow, collects events or result, and returns as formatted text content.case "run_workflow": { const params = RunWorkflowSchema.parse(args); if (params.stream) { const stream = await fal.stream(params.workflow_id, { input: params.input, }); const events: any[] = []; for await (const event of stream) { events.push({ type: event.type, data: event.data, }); } return { content: [ { type: "text", text: JSON.stringify(events, null, 2), }, ], }; } else { const result = await fal.subscribe(params.workflow_id, { input: params.input, logs: true, }); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; } }
- src/index.ts:77-81 (schema)Zod schema definition for validating inputs to the 'run_workflow' tool: workflow_id (required), input (required), stream (optional boolean).const RunWorkflowSchema = z.object({ workflow_id: z.string().describe("The workflow ID (e.g., 'workflows/fal-ai/sdxl-sticker')"), input: z.record(z.any()).describe("Input parameters for the workflow"), stream: z.boolean().default(false).optional().describe("Whether to stream workflow events"), });
- src/index.ts:161-183 (registration)Tool registration in the ListTools response, defining name, description, and inputSchema matching the Zod schema.{ name: "run_workflow", description: "Run a Fal.ai workflow (e.g., sdxl-sticker pipeline)", inputSchema: { type: "object", properties: { workflow_id: { type: "string", description: "The workflow ID", }, input: { type: "object", description: "Input parameters for the workflow", }, stream: { type: "boolean", description: "Whether to stream workflow events", default: false, }, }, required: ["workflow_id", "input"], }, },