Skip to main content
Glama

text_to_image

Generate custom images from text descriptions using AI. Enter a detailed prompt to create visual content for various applications.

Instructions

Generate an image from a text prompt using Nanana AI. This operation typically takes 15-30 seconds to complete. The tool will wait for generation to finish and return the final image URL.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYesThe text prompt describing the image to generate

Implementation Reference

  • Core handler function that executes the text-to-image generation by calling the Nanana AI API, handling errors, and returning the image URL.
    async function callTextToImage( apiToken: string, params: TextToImageParams ): Promise<{ imageUrl: string; imageBase64: string; prompt: string }> { const response = await fetch(`${API_BASE_URL}/api/mcp/v1/text-to-image`, { method: "POST", headers: { Authorization: `Bearer ${apiToken}`, "Content-Type": "application/json", }, body: JSON.stringify({ prompt: params.prompt }), }); if (!response.ok) { const error = (await response.json().catch(() => ({}))) as { error?: string; }; throw new Error( error.error || `API request failed with status ${response.status}` ); } const data = (await response.json()) as { imageUrl: string; prompt: string }; // Download image and convert to base64 // const imageBase64 = await imageUrlToBase64(data.imageUrl); const imageBase64 = ""; return { imageUrl: data.imageUrl, imageBase64, prompt: data.prompt }; }
  • MCP protocol handler dispatch for text_to_image tool call, logging, invoking core handler, and formatting response content.
    if (name === "text_to_image") { const params = args as unknown as TextToImageParams; console.error( `[MCP] Starting text-to-image generation: "${params.prompt}"` ); const result = await callTextToImage(apiToken, params); console.error(`[MCP] Generation completed: ${result.imageUrl}`); return { content: [ { type: "text", text: `Successfully generated image!\n\nPrompt: ${result.prompt}\n\nImage URL: ${result.imageUrl}`, }, ], };
  • Type definition for input parameters of the text_to_image tool.
    interface TextToImageParams { prompt: string; }
  • src/index.ts:24-38 (registration)
    Tool registration object defining name, description, and input schema for text_to_image.
    const TEXT_TO_IMAGE_TOOL: Tool = { name: "text_to_image", description: "Generate an image from a text prompt using Nanana AI. This operation typically takes 15-30 seconds to complete. The tool will wait for generation to finish and return the final image URL.", inputSchema: { type: "object", properties: { prompt: { type: "string", description: "The text prompt describing the image to generate", }, }, required: ["prompt"], }, };
  • src/index.ts:162-165 (registration)
    Registration of available tools in the MCP listTools handler, including text_to_image.
    return { tools: [TEXT_TO_IMAGE_TOOL, IMAGE_TO_IMAGE_TOOL], }; });

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/nanana-app/mcp-server-nano-banana'

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