Skip to main content
Glama

generateImageUrl

Generate an image URL from a text prompt. Override defaults for model, size, seed, and other settings as needed.

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 handler: Builds a Pollinations image URL from a prompt with parameters (model, seed, width, height, enhance, safe) and returns the URL with 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
      };
    }
  • Input schema for generateImageUrl tool defining properties: prompt (required string), 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 handler that routes 'generateImageUrl' tool calls, merges default config with user args, invokes the service, and returns results.
    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/index.js:1-29 (registration)
    Re-exports generateImageUrl from imageService.js as the public API entry point.
    /**
     * Pollinations API Client
     *
     * A simple client for the Pollinations APIs that follows the thin proxy design principle
     */
    
    // Import services
    import { generateImageUrl, generateImage, editImage, generateImageFromReference, listImageModels } from './services/imageService.js';
    import { respondAudio, listAudioVoices } from './services/audioService.js';
    import { respondText, listTextModels } from './services/textService.js';
    
    
    // Export all service functions
    export {
      // Image services
      generateImageUrl,
      generateImage,
      editImage,
      generateImageFromReference,
      listImageModels,
    
      // Audio services
      respondAudio,
      listAudioVoices,
    
      // Text services
      respondText,
      listTextModels,
    };
  • src/schemas.js:32-44 (registration)
    Registers generateImageUrlSchema in the getAllToolSchemas() array for tool listing.
    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?

No annotations are provided, so the description carries full burden. It states it generates an image URL but does not disclose behavioral traits such as whether it modifies state, requires authentication, has rate limits, or what errors might occur. The description is too brief to convey important behavioral details.

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 two sentences, with no superfluous words. It front-loads the core action and quickly adds a note about configuration. No wasted text.

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 no annotations and no output schema, the description should provide more context about the tool's behavior, such as how the URL is returned, expected latency, error handling, or state changes. It feels incomplete for a generative tool with 7 parameters.

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 input schema has 100% description coverage, so the baseline is 3. The description adds that user-configured settings can be overridden per parameter, but this is a general note rather than adding specific meaning to parameters beyond what the schema already provides.

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 and resource: 'Generate an image URL from a text prompt.' It provides a specific verb and resource, making the tool's purpose clear. However, it does not explicitly distinguish this from sibling tools like `generateImage` or `generateImageFromReference`, though the name hints at the difference.

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 mentions that user-configured settings in MCP config will be used as defaults, giving some context on configuration. However, it does not provide explicit guidance on when to use this tool versus alternatives (e.g., `generateImage` or `editImage`), nor does it specify when not to use it.

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