Skip to main content
Glama

run_model

Execute any Fal.ai model with custom inputs to generate AI images, supporting real-time streaming and workflow integration.

Instructions

Run any Fal.ai model with custom parameters

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputYesInput parameters for the model
model_idYesThe Fal.ai model endpoint ID
streamNoWhether to stream results

Implementation Reference

  • Handler for run_model tool: parses input using RunModelSchema, then either streams or subscribes to fal.ai model execution based on stream flag, and returns JSON stringified result.
    case "run_model": { const params = RunModelSchema.parse(args); if (params.stream) { const stream = await fal.stream(params.model_id, { input: params.input, }); const events: any[] = []; for await (const event of stream) { events.push(event); } return { content: [ { type: "text", text: JSON.stringify(events, null, 2), }, ], }; } else { const result = await fal.subscribe(params.model_id, { input: params.input, logs: true, }); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; } }
  • Zod schema defining input for run_model: model_id (required), input (required), stream (optional boolean).
    const RunModelSchema = z.object({ model_id: z.string().describe("The Fal.ai model endpoint ID (e.g., 'fal-ai/flux/dev')"), input: z.record(z.any()).describe("Input parameters for the model"), stream: z.boolean().default(false).optional().describe("Whether to stream results"), });
  • src/index.ts:138-160 (registration)
    Registration of run_model tool in the list of tools returned by ListToolsRequestHandler, including name, description, and inputSchema matching the Zod schema.
    { name: "run_model", description: "Run any Fal.ai model with custom parameters", inputSchema: { type: "object", properties: { model_id: { type: "string", description: "The Fal.ai model endpoint ID", }, input: { type: "object", description: "Input parameters for the model", }, stream: { type: "boolean", description: "Whether to stream results", default: false, }, }, required: ["model_id", "input"], }, },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Gravicity/fal-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server