Created
August 13, 2025 17:29
-
-
Save ZTRdiamond/a36606b61f4fd80ff99f3b802bbe2564 to your computer and use it in GitHub Desktop.
n8n tools text2image testing from their website
This file contains hidden or 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
| import axios from "axios"; | |
| function ip() { | |
| const x = (a) => (Math.random() * a).toFixed(); | |
| return `${x(300)}.${x(300)}.${x(300)}.${x(300)}`; | |
| } | |
| export default async function txt2img(prompt) { | |
| try { | |
| return new Promise((resolve, reject) => { | |
| if(!prompt) throw "missing prompt input"; | |
| axios.post("https://internal.users.n8n.cloud/webhook/ai_image_generator", { | |
| prompt | |
| }, { | |
| headers: { | |
| 'Content-Type': 'application/json', | |
| 'User-Agent': 'Zanixon/1.0.0', | |
| 'X-Client-Ip': ip() | |
| } | |
| }).then(raw => { | |
| const data = raw.data; | |
| if(!data.result) throw "failed generatig image"; | |
| resolve({ | |
| success: true, | |
| images: data.result | |
| }) | |
| }).catch(reject) | |
| }) | |
| } catch (e) { | |
| return { | |
| success: true, | |
| errors: e | |
| } | |
| } | |
| } | |
| txt2img("kucing lucu berjalan di pinggir trotoar") | |
| .then(console.log) | |
| .catch(console.log) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
VID_20250807_202535_292.mp4