recraft_v3
Generate professional designs and illustrations with tailored image sizes and quantities using advanced AI models on the FAL Image/Video MCP Server.
Instructions
Recraft V3 - Professional design and illustration
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| image_size | No | landscape_4_3 | |
| num_images | No | ||
| prompt | Yes | Text prompt for image generation |
Implementation Reference
- src/index.ts:104-104 (registration)Registration of the 'recraft_v3' tool model definition in MODEL_REGISTRY.imageGeneration array, specifying its ID, FAL endpoint, name, and description.{ id: 'recraft_v3', endpoint: 'fal-ai/recraft/v3/text-to-image', name: 'Recraft V3', description: 'Professional design and illustration' },
- src/index.ts:357-373 (schema)Dynamic generation of input schema for image generation tools including recraft_v3, defining parameters like prompt, image_size, num_images, and model-specific options.if (category === 'imageGeneration') { baseSchema.inputSchema.properties = { prompt: { type: 'string', description: 'Text prompt for image generation' }, image_size: { type: 'string', enum: ['square_hd', 'square', 'portrait_4_3', 'portrait_16_9', 'landscape_4_3', 'landscape_16_9'], default: 'landscape_4_3' }, num_images: { type: 'number', default: 1, minimum: 1, maximum: 4 }, }; baseSchema.inputSchema.required = ['prompt']; // Add model-specific parameters if (model.id.includes('flux') || model.id.includes('stable_diffusion')) { baseSchema.inputSchema.properties.num_inference_steps = { type: 'number', default: 25, minimum: 1, maximum: 50 }; baseSchema.inputSchema.properties.guidance_scale = { type: 'number', default: 3.5, minimum: 1, maximum: 20 }; } if (model.id.includes('stable_diffusion') || model.id === 'ideogram_v3') { baseSchema.inputSchema.properties.negative_prompt = { type: 'string', description: 'Negative prompt' }; } } else if (category === 'textToVideo') {
- src/index.ts:495-563 (handler)Core handler function for recraft_v3 (and other image gen tools). Configures FAL client, builds input params based on model type, calls fal.subscribe on 'fal-ai/recraft/v3/text-to-image', processes output images with downloads/data URLs, and returns formatted content.private async handleImageGeneration(args: any, model: any) { const { prompt, image_size = 'landscape_4_3', num_inference_steps = 25, guidance_scale = 3.5, num_images = 1, negative_prompt, safety_tolerance, raw, } = args; try { // Configure FAL client lazily with query config override configureFalClient(this.currentQueryConfig); const inputParams: any = { prompt }; // Add common parameters if (image_size) inputParams.image_size = image_size; if (num_images > 1) inputParams.num_images = num_images; // Add model-specific parameters based on model capabilities if (model.id.includes('flux') || model.id.includes('stable_diffusion')) { if (num_inference_steps) inputParams.num_inference_steps = num_inference_steps; if (guidance_scale) inputParams.guidance_scale = guidance_scale; } if ((model.id.includes('stable_diffusion') || model.id === 'ideogram_v3') && negative_prompt) { inputParams.negative_prompt = negative_prompt; } if (model.id.includes('flux_pro') && safety_tolerance) { inputParams.safety_tolerance = safety_tolerance; } if (model.id === 'flux_pro_ultra' && raw !== undefined) { inputParams.raw = raw; } const result = await fal.subscribe(model.endpoint, { input: inputParams }); const imageData = result.data as FalImageResult; const processedImages = await downloadAndProcessImages(imageData.images, model.id); return { content: [ { type: 'text', text: JSON.stringify({ model: model.name, id: model.id, endpoint: model.endpoint, prompt, images: processedImages, metadata: inputParams, download_path: DOWNLOAD_PATH, data_url_settings: { enabled: ENABLE_DATA_URLS, max_size_mb: Math.round(MAX_DATA_URL_SIZE / 1024 / 1024), }, autoopen_settings: { enabled: AUTOOPEN, note: AUTOOPEN ? "Files automatically opened with default application" : "Auto-open disabled" }, }, null, 2), }, ], }; } catch (error) { throw new Error(`${model.name} generation failed: ${error}`); } }
- src/index.ts:139-143 (helper)Helper function to retrieve the model configuration (endpoint, etc.) by tool name 'recraft_v3' for use in handler dispatch.// Helper function to get model by ID function getModelById(id: string) { const allModels = getAllModels(); return allModels.find(model => model.id === id); }
- src/index.ts:255-287 (helper)Helper to process generated images: downloads to local path, converts to data URLs if enabled, auto-opens files, for inclusion in tool response.async function downloadAndProcessImages(images: any[], modelName: string): Promise<any[]> { const processedImages = await Promise.all( images.map(async (image, index) => { const filename = generateFilename('image', modelName, images.length > 1 ? index : undefined); const localPath = await downloadFile(image.url, filename); const dataUrl = await urlToDataUrl(image.url); // Auto-open the downloaded image if available if (localPath) { await autoOpenFile(localPath); } const result: any = { url: image.url, width: image.width, height: image.height, }; // Only include localPath if download was successful if (localPath) { result.localPath = localPath; } // Only include dataUrl if it was successfully generated if (dataUrl) { result.dataUrl = dataUrl; } return result; }) ); return processedImages;