Skip to main content
Glama

generate_batch

Generate multiple images simultaneously in a single call to improve efficiency when creating batches of up to 10 images from text prompts.

Instructions

Generate multiple images in one call (up to 10). More efficient than calling generate_image repeatedly.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptsYesArray of image prompts to generate (max 10)

Implementation Reference

  • The handler function for 'generate_batch' which iterates through provided prompts, validates them, and generates image URLs.
    export async function handleGenerateBatch(
      args: z.infer<typeof generateBatchSchema>
    ) {
      const results: string[] = [];
    
      for (const item of args.prompts) {
        const model = getModel(item.model);
        if (!model || model.type !== "image") {
          results.push(`❌ ${item.prompt.slice(0, 40)}... — unknown model: ${item.model}`);
          continue;
        }
        if (!model.free && !API_KEY) {
          results.push(`❌ ${item.prompt.slice(0, 40)}... — model "${item.model}" requires API key`);
          continue;
        }
    
        const params = new URLSearchParams({
          model: item.model,
          width: String(item.width ?? 1024),
          height: String(item.height ?? 1024),
          nologo: "true",
          seed: String(item.seed ?? Math.floor(Math.random() * 999999999)),
        });
        if (API_KEY) params.set("token", API_KEY);
    
        const url = `https://gen.pollinations.ai/image/${encodeURIComponent(item.prompt)}?${params}`;
        results.push(`✅ ${item.prompt.slice(0, 50)}...\n   Model: ${model.name} | URL: ${url}`);
      }
    
      return {
        content: [
          {
            type: "text" as const,
            text: [`Batch generation (${args.prompts.length} items):`, "", ...results].join("\n"),
          },
        ],
      };
    }
  • Zod schema definition for 'generate_batch' inputs.
    export const generateBatchSchema = z.object({
      prompts: z
        .array(
          z.object({
            prompt: z.string().describe("Text prompt"),
            model: z.string().default("flux").describe("Model ID"),
            width: z.number().default(1024).optional(),
            height: z.number().default(1024).optional(),
            seed: z.number().optional(),
          })
        )
        .min(1)
        .max(10)
        .describe("Array of image prompts to generate (max 10)"),
    });
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions efficiency but lacks critical details: it doesn't specify authentication needs, rate limits, cost implications, error handling, or what the output looks like (e.g., format, structure). For a batch generation tool with no annotation coverage, this is a significant gap.

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 two sentences with zero waste: the first states the purpose and constraint, the second provides usage guidance. It's appropriately sized and front-loaded, making every sentence earn its place.

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?

Given the complexity of a batch image generation tool with no annotations and no output schema, the description is incomplete. It lacks details on behavioral aspects (e.g., authentication, rate limits), output format, and error handling. While the schema covers parameters well, the overall context for safe and effective use is insufficient.

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 the single parameter 'prompts' and its nested properties. The description adds minimal value beyond the schema by implying batch processing and efficiency, but doesn't provide additional syntax, format details, or constraints beyond what's in the schema. Baseline 3 is appropriate when the schema does the heavy lifting.

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 tool's purpose: 'Generate multiple images in one call (up to 10).' It specifies the verb ('generate'), resource ('images'), and scope ('multiple...up to 10'). However, it doesn't explicitly differentiate from its sibling 'generate_image' beyond mentioning efficiency, which is good but not a full distinction.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool: 'More efficient than calling generate_image repeatedly.' This implies an alternative (generate_image) and suggests usage for batch processing. However, it doesn't explicitly state when NOT to use it or other alternatives, which keeps it from a perfect score.

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/doctorm333/promptpilot-mcp-server'

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