Skip to main content
Glama

generate_image

Create images from text prompts using AI models. Specify dimensions and settings to generate visual content for various applications.

Instructions

Generate an image using Pollinations API. Returns a URL to the generated image.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYesText prompt for image generation
modelNoModel ID (default: flux)flux
widthNoImage width
heightNoImage height
enhanceNoEnhance prompt with AI
seedNoSeed for reproducibility

Implementation Reference

  • The handler function for the 'generate_image' tool, which processes the input arguments, validates the model, builds the Pollinations API URL, and returns the result.
    export async function handleGenerateImage(
      args: z.infer<typeof generateImageSchema>
    ) {
      const model = getModel(args.model);
      if (!model || model.type !== "image") {
        return {
          content: [
            {
              type: "text" as const,
              text: `Unknown image model: ${args.model}. Use list_models to see available models.`,
            },
          ],
          isError: true,
        };
      }
      if (!model.free && !API_KEY) {
        return {
          content: [
            {
              type: "text" as const,
              text: `Model "${args.model}" requires a Pollinations API key. Set POLLINATIONS_API_KEY env variable.`,
            },
          ],
          isError: true,
        };
      }
    
      const params = new URLSearchParams({
        model: args.model,
        width: String(args.width),
        height: String(args.height),
        enhance: String(args.enhance),
        nologo: "true",
      });
      if (args.seed !== undefined) params.set("seed", String(args.seed));
      if (API_KEY) params.set("token", API_KEY);
    
      const encodedPrompt = encodeURIComponent(args.prompt);
      const url = `https://gen.pollinations.ai/image/${encodedPrompt}?${params}`;
    
      return {
        content: [
          {
            type: "text" as const,
            text: [
              `Image generated successfully!`,
              `Model: ${model.name}`,
              `Size: ${args.width}x${args.height}`,
              `URL: ${url}`,
            ].join("\n"),
          },
        ],
      };
    }
  • The Zod schema definition for the 'generate_image' tool input parameters.
    export const generateImageSchema = z.object({
      prompt: z.string().describe("Text prompt for image generation"),
      model: z.string().default("flux").describe("Model ID (default: flux)"),
      width: z.number().min(256).max(2048).default(1024).describe("Image width"),
      height: z.number().min(256).max(2048).default(1024).describe("Image height"),
      enhance: z.boolean().default(true).describe("Enhance prompt with AI"),
      seed: z.number().optional().describe("Seed for reproducibility"),
    });
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the API (Pollinations) and return type (URL), but fails to disclose critical traits like rate limits, authentication needs, cost implications, error handling, or whether the operation is idempotent. This leaves significant gaps for a tool that likely involves external API calls.

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—two sentences that efficiently state the tool's purpose and output. It is front-loaded with the core functionality and wastes no words, making it easy to parse quickly.

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 an image generation tool with external API integration, no annotations, and no output schema, the description is insufficient. It omits details about behavioral traits (e.g., rate limits, costs), usage context compared to siblings, and output specifics beyond a URL, leaving the agent under-informed for effective use.

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?

The description adds no parameter-specific information beyond what the input schema provides, which has 100% coverage with detailed descriptions for all 6 parameters. Since the schema fully documents parameters like prompt, model, and dimensions, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

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 ('Generate an image') and resource ('using Pollinations API'), and specifies the return value ('Returns a URL to the generated image'). It distinguishes from siblings like generate_audio and generate_video by focusing on image generation, though it doesn't explicitly contrast with generate_batch or other image-related tools.

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 generate_batch for multiple images or list_models for model selection. It lacks context about prerequisites, such as needing a prompt, or when not to use it, such as for audio or video generation.

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