Skip to main content
Glama

generateImageUrl

Create image URLs by converting text prompts into visuals using specified dimensions and models for consistent results.

Instructions

Generate an image URL from a text prompt

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
optionsNoAdditional options for image generation
promptYesThe text description of the image to generate

Implementation Reference

  • Main handler function for the generateImageUrl MCP tool. Validates input parameters and delegates to internal helper before returning formatted MCP response.
    async function generateImageUrl(params) { const { prompt, options = {} } = params; if (!prompt || typeof prompt !== "string") { throw new Error("Prompt is required and must be a string"); } // Generate the image URL and metadata const result = await _generateImageUrlInternal(prompt, options); // Return the response in MCP format return createMCPResponse([createTextContent(result, true)]); }
  • Core internal helper that builds the Pollinations image API URL with prompt and options, returns URL and metadata.
    async function _generateImageUrlInternal(prompt, options = {}) { const { model, seed, width = 1024, height = 1024 } = options; // Construct the URL with query parameters const encodedPrompt = encodeURIComponent(prompt); const path = `prompt/${encodedPrompt}`; const queryParams = { model, seed, width, height }; const url = buildUrl(IMAGE_API_BASE_URL, path, queryParams); // Return the URL with metadata return { imageUrl: url, prompt, width, height, model, seed, }; }
  • Zod schema defining input parameters for the generateImageUrl tool: required prompt string and optional options object.
    { prompt: z .string() .describe("The text description of the image to generate"), options: z .object({ model: z .string() .optional() .describe("Model name to use for generation"), seed: z .number() .optional() .describe("Seed for reproducible results"), width: z .number() .optional() .describe("Width of the generated image"), height: z .number() .optional() .describe("Height of the generated image"), }) .optional() .describe("Additional options for image generation"), },
  • Registration array for the generateImageUrl tool within imageTools export, including name, description, schema, and handler reference. Imported and spread into main toolDefinitions for server.tool() registration.
    [ "generateImageUrl", "Generate an image URL from a text prompt", { prompt: z .string() .describe("The text description of the image to generate"), options: z .object({ model: z .string() .optional() .describe("Model name to use for generation"), seed: z .number() .optional() .describe("Seed for reproducible results"), width: z .number() .optional() .describe("Width of the generated image"), height: z .number() .optional() .describe("Height of the generated image"), }) .optional() .describe("Additional options for image generation"), }, generateImageUrl, ],

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/tusharpatil2912/pollinations-mcp'

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