Skip to main content
Glama

letzai_create_image

Generate custom images using AI by providing a text prompt. Adjust settings like creativity, quality, mode, and dimensions to create photorealistic or artistic visuals.

Instructions

Create an image using the LetzAI public api

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
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
heightNoHeight of the image should be between 520 and 2160 max pixels. Default is 1600.
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
promptYesImage prompt to generate a new image. Can also include @tag to generate an image using a model from the LetzAi Platform
qualityNoDefines how many steps the generation should take. Higher is slower, but generally better quality. Min: 1, Default: 2, Max: 5
systemVersionNoAllowed values: 2, 3. UseLetzAI V2, or V3 (newest).
widthNoWidth of the image should be between 520 and 2160 max pixels. Default is 1600.

Implementation Reference

  • The core handler for the letzai_create_image tool within the CallToolRequestSchema handler. It validates and processes input parameters, calls the LetzAI API to generate an image, polls for completion with progress updates, opens the image in the browser, and returns a success message with the image 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") {
  • The tool definition object including name, description, and detailed inputSchema for parameter validation in the letzai_create_image tool.
    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)
    Registration of the letzai_create_image tool (imported as createImageTool) in the list of available tools provided to clients via ListToolsRequestSchema.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [createImageTool, upscaleImageTool], }; });
  • Helper constant defining valid modes for image generation, referenced in the schema and used in handler for validation.
    export const modes = ["default", "turbo", "sigma"];
  • src/index.ts:27-28 (registration)
    Invocation of setTools which registers all tool handlers including letzai_create_image on the MCP server.
    //All available tools in tools.ts (create image, get image) setTools(server);

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

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