Skip to main content
Glama

generateImageUrl

Create image URLs from text descriptions using AI models, with configurable settings for dimensions, models, and content preferences.

Instructions

Generate an image URL from a text prompt. User-configured settings in MCP config will be used as defaults unless specifically overridden.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYesThe text description of the image to generate
modelNoModel name to use for generation (default: user config or "flux"). Use listImageModels to see all available models
seedNoSeed for reproducible results (default: random)
widthNoWidth of the generated image (default: 1024)
heightNoHeight of the generated image (default: 1024)
enhanceNoWhether to enhance the prompt using an LLM before generating (default: true)
safeNoWhether to apply content filtering (default: false)

Implementation Reference

  • Core implementation of generateImageUrl: constructs Pollinations API URL with prompt, model, dimensions, seed, enhance, safe flags, nologo and private=true, returns {imageUrl, metadata}.
    export async function generateImageUrl(prompt, model = 'flux', seed = Math.floor(Math.random() * 1000000), width = 1024, height = 1024, enhance = true, safe = false, authConfig = null) {
      if (!prompt || typeof prompt !== 'string') {
        throw new Error('Prompt is required and must be a string');
      }
    
      // Parameters are now directly passed as function arguments
    
      // Build the query parameters
      const queryParams = new URLSearchParams();
    
      // Always include model (with default 'flux')
      queryParams.append('model', model);
    
      // Add other parameters
      if (seed !== undefined) queryParams.append('seed', seed);
      if (width) queryParams.append('width', width);
      if (height) queryParams.append('height', height);
    
      // Add enhance parameter if true
      if (enhance) queryParams.append('enhance', 'true');
    
      // Add parameters
      queryParams.append('nologo', 'true'); // Always set nologo to true
      queryParams.append('private', 'true'); // Always set private to true)
      queryParams.append('safe', safe.toString()); // Use the customizable safe parameter
    
      // Construct the URL
      const encodedPrompt = encodeURIComponent(prompt);
      const baseUrl = 'https://image.pollinations.ai';
      let url = `${baseUrl}/prompt/${encodedPrompt}`;
    
      // Add query parameters
      const queryString = queryParams.toString();
      url += `?${queryString}`;
    
      // Return the URL directly, keeping it simple
      return {
        imageUrl: url,
        prompt,
        width,
        height,
        model,
        seed,
        enhance,
        private: true,
        nologo: true,
        safe
      };
    }
  • JSON schema defining input parameters for the generateImageUrl tool: prompt (required), model, seed, width, height, enhance, safe.
    export const generateImageUrlSchema = {
      name: 'generateImageUrl',
      description: 'Generate an image URL from a text prompt. User-configured settings in MCP config will be used as defaults unless specifically overridden.',
      inputSchema: {
        type: 'object',
        properties: {
          prompt: {
            type: 'string',
            description: 'The text description of the image to generate'
          },
          model: {
            type: 'string',
            description: 'Model name to use for generation (default: user config or "flux"). Use listImageModels to see all available models'
          },
          seed: {
            type: 'number',
            description: 'Seed for reproducible results (default: random)'
          },
          width: {
            type: 'number',
            description: 'Width of the generated image (default: 1024)'
          },
          height: {
            type: 'number',
            description: 'Height of the generated image (default: 1024)'
          },
          enhance: {
            type: 'boolean',
            description: 'Whether to enhance the prompt using an LLM before generating (default: true)'
          },
          safe: {
            type: 'boolean',
            description: 'Whether to apply content filtering (default: false)'
          }
        },
        required: ['prompt']
      }
    };
  • MCP server dispatch handler for 'generateImageUrl' tool call: extracts arguments with defaults from config/env, calls generateImageUrl service function, returns JSON stringified result or error.
    if (name === 'generateImageUrl') {
      try {
        const { prompt, model = defaultConfig.image.model, seed, width = defaultConfig.image.width, height = defaultConfig.image.height, enhance = defaultConfig.image.enhance, safe = defaultConfig.image.safe } = args;
        const result = await generateImageUrl(prompt, model, seed, width, height, enhance, safe, finalAuthConfig);
        return {
          content: [
            { type: 'text', text: JSON.stringify(result, null, 2) }
          ]
        };
      } catch (error) {
        return {
          content: [
            { type: 'text', text: `Error generating image URL: ${error.message}` }
          ],
          isError: true
        };
      }
  • src/schemas.js:32-44 (registration)
    getAllToolSchemas function includes generateImageUrlSchema; used by MCP server's ListToolsRequestHandler to register the tool schema.
    export function getAllToolSchemas() {
      return [
        generateImageUrlSchema,
        generateImageSchema,
        editImageSchema,
        generateImageFromReferenceSchema,
        listImageModelsSchema,
        respondAudioSchema,
        listAudioVoicesSchema,
        respondTextSchema,
        listTextModelsSchema
      ];
    }
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 that defaults come from user configuration, which adds useful context about behavior. However, it doesn't describe critical aspects like whether this is a read-only or write operation, potential rate limits, authentication requirements, or what happens on failure. For a tool that likely involves external API calls and resource generation, 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 extremely concise - just two sentences that efficiently convey the core functionality and configuration behavior. Every word earns its place with no redundancy or unnecessary elaboration. It's front-loaded with the main purpose followed by important behavioral context.

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

Completeness3/5

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

Given the tool's complexity (7 parameters, likely involves external API calls) and the absence of both annotations and output schema, the description is somewhat incomplete. While it states the purpose and configuration behavior, it doesn't address what the tool returns (beyond 'image URL'), error conditions, or performance characteristics. However, the excellent parameter documentation in the schema partially compensates for these gaps.

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 7 parameters thoroughly with descriptions and defaults. The description doesn't add any parameter-specific information beyond what's in the schema. According to scoring rules, when schema coverage is high (>80%), the baseline is 3 even with no param info in the description.

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 an image URL from a text prompt.' This specifies the verb (generate), resource (image URL), and input type (text prompt). However, it doesn't distinguish this tool from its sibling 'generateImage' - both appear to generate images from text prompts, so the distinction isn't clear.

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

Usage Guidelines3/5

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

The description provides some usage context by mentioning that 'User-configured settings in MCP config will be used as defaults unless specifically overridden,' which implies this tool respects configuration defaults. However, it doesn't explicitly state when to use this tool versus alternatives like 'generateImage' or 'generateImageFromReference' among the sibling tools, leaving the agent to infer usage scenarios.

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/pinkpixel-dev/MCPollinations'

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