Skip to main content
Glama

letzai_create_image

Generate custom images from text prompts using AI, with adjustable dimensions, quality, creativity levels, and generation modes.

Instructions

Create an image using the LetzAI public api

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYesImage prompt to generate a new image. Can also include @tag to generate an image using a model from the LetzAi Platform
widthNoWidth of the image should be between 520 and 2160 max pixels. Default is 1600.
heightNoHeight of the image should be between 520 and 2160 max pixels. Default is 1600.
qualityNoDefines how many steps the generation should take. Higher is slower, but generally better quality. Min: 1, Default: 2, Max: 5
creativityNoDefines how strictly the prompt should be respected. Higher Creativity makes the images more artificial. Lower makes it more photorealistic. Min: 1, Default: 2, Max: 5
hasWatermarkNoDefines whether to set a watermark or not. Default is true
systemVersionNoAllowed values: 2, 3. UseLetzAI V2, or V3 (newest).
modeNoSelect one of the different modes that offer different generation settings. Allowed values: default, sigma, turbo. Default is slow but high quality. Sigma is faster and great for close ups. Turbo is fastest, but lower quality.turbo

Implementation Reference

  • Main execution logic for the letzai_create_image tool. Parses arguments, calls LetzAI API to generate image, polls status with progress updates via console, opens image in browser, returns text content with URL.
    if (request.params.name === "letzai_create_image") { try { let { prompt, width, height, quality, creativity, hasWatermark, systemVersion, mode, } = request.params.arguments as any; mode = !mode || !mode.includes(mode || "") ? "turbo" : mode; width = parseInt(width) || 1600; height = parseInt(height) || 1600; quality = parseInt(quality) || 2; creativity = parseInt(creativity) || 2; systemVersion = parseInt(systemVersion) || 3; hasWatermark = typeof hasWatermark === "boolean" ? hasWatermark : false; // Step 1: Create the image request const responseCreate = await axios.post( "https://api.letz.ai/images", { prompt, width, height, quality, creativity, hasWatermark, systemVersion, mode, }, { headers: { Authorization: `Bearer ${process.env.LETZAI_API_KEY}`, }, } ); let imageFinished = false; let imageVersions: { original: string; "96x96": string; "240x240": string; "640x640": string; "1920x1920": string; } | null = null; let imageId = responseCreate.data.id; // Step 2: Poll for image creation status while (!imageFinished) { await new Promise((resolve) => setTimeout(resolve, 5000)); // Wait before checking again const responseImage = await axios.get( `https://api.letz.ai/images/${imageId}`, { headers: { Authorization: `Bearer ${process.env.LETZAI_API_KEY}`, }, } ); if (responseImage.data.progress < 100) { // Send a progress notification (through stdout for Stdio transport) console.log( JSON.stringify({ jsonrpc: "2.0", method: "progress_update", params: { message: `Image is still being processed. Progress: ${responseImage.data.progress}%`, }, }) ); } else { imageFinished = true; imageVersions = responseImage.data.imageVersions; } } // Convert the image to Base64 after processing is complete /* const imageBase64 = convertImageUrlToBase64( imageVersions?.["640x640"] as string ); */ // Open the image in browser open(imageVersions?.original as string); // Return the response to the client return { content: [ { type: "text", text: `Image generated successfully!\nThe image has been opened in your default browser.\n\n Image URL: ${imageVersions?.original}\n\nYou can also click the URL above to view the image again.`, }, ], }; } catch (err: any) { return { content: [ { type: "text", text: `Error happened: ${err.toString()}`, }, ], }; } } else if (request.params.name === "letzai_upscale_image") {
  • Input schema and metadata for the letzai_create_image tool, defining parameters like prompt, dimensions, quality, and mode.
    export const createImageTool = { name: "letzai_create_image", description: "Create an image using the LetzAI public api", inputSchema: { type: "object", properties: { prompt: { type: "string", description: "Image prompt to generate a new image. Can also include @tag to generate an image using a model from the LetzAi Platform", }, width: { type: "number", default: 1600, description: "Width of the image should be between 520 and 2160 max pixels. Default is 1600.", }, height: { type: "number", default: 1600, description: "Height of the image should be between 520 and 2160 max pixels. Default is 1600.", }, quality: { type: "number", default: 2, description: "Defines how many steps the generation should take. Higher is slower, but generally better quality. Min: 1, Default: 2, Max: 5", }, creativity: { type: "number", default: 2, description: "Defines how strictly the prompt should be respected. Higher Creativity makes the images more artificial. Lower makes it more photorealistic. Min: 1, Default: 2, Max: 5", }, hasWatermark: { type: "boolean", default: true, description: "Defines whether to set a watermark or not. Default is true", }, systemVersion: { type: "number", default: 3, description: "Allowed values: 2, 3. UseLetzAI V2, or V3 (newest).", }, mode: { type: "string", default: "turbo", enum: modes, description: "Select one of the different modes that offer different generation settings. Allowed values: default, sigma, turbo. Default is slow but high quality. Sigma is faster and great for close ups. Turbo is fastest, but lower quality.", }, }, required: ["prompt"], }, };
  • src/tools.ts:13-17 (registration)
    Registers the letzai_create_image tool (as createImageTool) in the list of available tools returned by ListToolsRequestSchema.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [createImageTool, upscaleImageTool], }; });
  • Helper constant defining available modes for image generation, used in schema enum and handler validation.
    export const modes = ["default", "turbo", "sigma"];
  • src/tools.ts:9-9 (registration)
    Import of the createImageTool schema and modes helper into the main tools file.
    import { createImageTool, modes } from "./tools/createImage.js";

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/Letz-AI/letzai-mcp'

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