Last active
October 25, 2024 09:32
-
-
Save taruma/784d334b3e524e727d0462a290929495 to your computer and use it in GitHub Desktop.
TypingMind Plugin for generating image with Flux.1 Dev via fal.ai
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id": "generate_image_with_falai_dev", | |
"code": "async function generate_image_with_falai_dev(params, userSettings) {\n const { prompt, image_size = \"landscape_4_3\", num_inference_steps = 28, enable_safety_checker = false, guidance_scale = 3.5 } = params;\n const { falApiKey } = userSettings;\n\n // Dynamic import of the fal.ai client\n const fal = await import('https://esm.sh/@fal-ai/serverless-client');\n\n // Configure the client with the API key\n fal.config({\n credentials: falApiKey\n });\n\n try {\n const result = await fal.subscribe(\"fal-ai/flux/dev\", {\n input: {\n prompt: prompt,\n image_size: image_size,\n num_inference_steps: num_inference_steps,\n enable_safety_checker: enable_safety_checker,\n guidance_scale: guidance_scale\n }\n });\n\n // Extract the image URL from the result\n const imageUrl = result.images[0].url;\n\n // Return the image result\n return {\n \"images\": [\n {\n \"url\": imageUrl,\n \"content_type\": \"image/jpeg\"\n }\n ],\n \"prompt\": prompt,\n \"alt_image\": prompt,\n };\n } catch (error) {\n console.error(\"Error generating image:\", error);\n return \"Error generating image. ${error}\";\n }\n}\n\n", | |
"uuid": "68cad28e-9692-47ef-a424-8084f7fbd4ad", | |
"emoji": "🧩", | |
"title": "Image Generator - Flux.1 Dev", | |
"iconURL": "", | |
"openaiSpec": { | |
"name": "generate_image_with_falai_dev", | |
"parameters": { | |
"type": "object", | |
"required": [ | |
"prompt" | |
], | |
"properties": { | |
"prompt": { | |
"type": "string", | |
"description": "The text prompt to generate an image from" | |
}, | |
"image_size": { | |
"enum": [ | |
"square_hd", | |
"square", | |
"portrait_4_3", | |
"portrait_16_9", | |
"landscape_4_3", | |
"landscape_16_9" | |
], | |
"type": "string", | |
"default": "landscape_4_3", | |
"description": "The size of the generated image" | |
}, | |
"num_inference_steps": { | |
"type": "integer", | |
"default": 28, | |
"description": "The number of inference steps to perform" | |
} | |
} | |
}, | |
"description": "Generate an image Flux.1 Dev Model via fal.ai based on a text prompt" | |
}, | |
"outputType": "respond_to_ai", | |
"userSettings": [ | |
{ | |
"name": "falApiKey", | |
"type": "password", | |
"label": "Fal.ai API Key", | |
"required": true | |
} | |
], | |
"overviewMarkdown": "## Fal.ai Image Generator (Dev)\n\nGenerate images using fal.ai's Flux Dev model.", | |
"implementationType": "javascript" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment