Skip to main content
Glama

generate_multiple_images

Create multiple images from an array of text prompts using the Flux Schnell model, with customizable aspect ratio, quality, and format. Ideal for generating diverse visuals quickly.

Instructions

Generate multiple images from an array of prompts using Flux Schnell model

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
aspect_ratioNoAspect ratio for the generated image1:1
disable_safety_checkerNoDisable safety checker for generated images.
go_fastNoRun faster predictions with model optimized for speed (currently fp8 quantized); disable to run in original bf16
megapixelsNoApproximate number of megapixels for generated image1
num_inference_stepsNoNumber of denoising steps. 4 is recommended, and lower number of steps produce lower quality outputs, faster.
output_formatNoFormat of the output imageswebp
output_qualityNoQuality when saving the output images, from 0 to 100. 100 is best quality, 0 is lowest quality. Not relevant for .png outputs
promptsYesArray of text descriptions for the images to generate
seedNoRandom seed. Set for reproducible generation
support_image_mcp_response_typeNoDisable if the image type is not supported in the response, if it's Cursor app for example

Implementation Reference

  • The main handler function that generates multiple images in parallel using the Replicate API with Flux Schnell model, processes results into MCP-compatible content including text descriptions and optional embedded images.
    export const registerGenerateMultipleImagesTool = async ( input: MultiImageGenerationParams ): Promise<CallToolResult> => { const { prompts, support_image_mcp_response_type, ...commonParams } = input; try { // Process all prompts in parallel const generationPromises = prompts.map(async (prompt) => { const [output] = (await replicate.run(CONFIG.imageModelId, { input: { prompt, ...commonParams, }, })) as [FileOutput]; const imageUrl = output.url() as unknown as string; if (support_image_mcp_response_type) { const imageBase64 = await outputToBase64(output); return { prompt, imageUrl, imageBase64, }; } return { prompt, imageUrl, }; }); // Wait for all image generation to complete const results = await Promise.all(generationPromises); // Build response content const responseContent: (TextContent | ImageContent)[] = []; // Add intro text responseContent.push({ type: "text", text: `Generated ${results.length} images based on your prompts:`, } as TextContent); // Add each image with its prompt for (const result of results) { responseContent.push({ type: "text", text: `\n\nPrompt: "${result.prompt}"\nImage URL: ${result.imageUrl}`, } as TextContent); if (support_image_mcp_response_type && result.imageBase64) { responseContent.push({ type: "image", data: result.imageBase64, mimeType: `image/${ input.output_format === "jpg" ? "jpeg" : input.output_format }`, } as ImageContent); } } return { content: responseContent, }; } catch (error) { handleError(error); } };
  • Zod schema defining input parameters for the generate_multiple_images tool, including array of prompts and shared image generation options.
    export const multiImageGenerationSchema = { prompts: z .array(z.string().min(1)) .min(1) .max(10) .describe("Array of text descriptions for the images to generate"), seed: z .number() .int() .optional() .describe("Random seed. Set for reproducible generation"), go_fast: z .boolean() .default(true) .describe( "Run faster predictions with model optimized for speed (currently fp8 quantized); disable to run in original bf16" ), megapixels: z .enum(["1", "0.25"]) .default("1") .describe("Approximate number of megapixels for generated image"), aspect_ratio: z .enum([ "1:1", "16:9", "21:9", "3:2", "2:3", "4:5", "5:4", "3:4", "4:3", "9:16", "9:21", ]) .default("1:1") .describe("Aspect ratio for the generated image"), output_format: z .enum(["webp", "jpg", "png"]) .default("webp") .describe("Format of the output images"), output_quality: z .number() .int() .min(0) .max(100) .default(80) .describe( "Quality when saving the output images, from 0 to 100. 100 is best quality, 0 is lowest quality. Not relevant for .png outputs" ), num_inference_steps: z .number() .int() .min(1) .max(4) .default(4) .describe( "Number of denoising steps. 4 is recommended, and lower number of steps produce lower quality outputs, faster." ), disable_safety_checker: z .boolean() .default(false) .describe("Disable safety checker for generated images."), support_image_mcp_response_type: z .boolean() .default(true) .describe( "Disable if the image type is not supported in the response, if it's Cursor app for example" ), };
  • Registration of the generate_multiple_images tool on the MCP server, linking name, description, input schema, and handler function.
    server.tool( "generate_multiple_images", "Generate multiple images from an array of prompts using Flux Schnell model", multiImageGenerationSchema, registerGenerateMultipleImagesTool );

Other Tools

Related 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/awkoy/replicate-flux-mcp'

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