Skip to main content
Glama

run_model

Execute AI image generation models on Fal.ai by specifying model endpoints and custom input parameters, enabling workflow automation and real-time processing.

Instructions

Run any Fal.ai model with custom parameters

Input Schema

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

Implementation Reference

  • Handler function for 'run_model' tool: parses input with RunModelSchema, then either streams or subscribes to the specified Fal.ai model using fal.stream or fal.subscribe, returning JSON results.
    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 parameters for the 'run_model' tool: model_id, input, and optional stream flag.
    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)
    Tool registration 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"],
      },
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states what the tool does but doesn't mention critical aspects like authentication requirements, rate limits, error handling, or whether this is a synchronous/asynchronous operation. The mention of 'custom parameters' is vague about constraints.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise at just 8 words with zero wasted language. It's front-loaded with the core purpose and efficiently communicates the essential function without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 3 parameters, no annotations, no output schema, and nested objects in the input, the description is insufficient. It doesn't explain what kind of response to expect, error conditions, or important behavioral aspects needed for proper tool invocation in a complex AI model execution context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all three parameters thoroughly. The description adds minimal value beyond what's in the schema - it mentions 'custom parameters' which aligns with the 'input' parameter but doesn't provide additional context about parameter formats or constraints.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Run') and resource ('any Fal.ai model'), specifying it's for models with custom parameters. However, it doesn't distinguish this from sibling tools like 'run_workflow' or 'generate_image', which might have overlapping purposes in the same AI platform context.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'run_workflow' or 'generate_image'. It mentions 'any Fal.ai model' but doesn't clarify if this is the primary tool for model execution or when other tools might be more appropriate.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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-archive/fal-mcp-server'

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