run_workflow
Execute Fal.ai workflows like the sdxl-sticker pipeline by providing workflow ID and input parameters to generate AI images.
Instructions
Run a Fal.ai workflow (e.g., sdxl-sticker pipeline)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workflow_id | Yes | The workflow ID | |
| input | Yes | Input parameters for the workflow | |
| stream | No | Whether to stream workflow events |
Implementation Reference
- src/index.ts:324-363 (handler)Switch case handling the execution of the 'run_workflow' tool. Parses input using RunWorkflowSchema, calls fal.stream or fal.subscribe on the workflow_id with input params, collects stream events or full 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 defining the input parameters for the run_workflow tool: workflow_id (required string), input (object), 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, including name, description, and JSON 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"], }, },