saw a video about OpenAI image generation and I had to try it out. Naturally node-red made this a 5 minute job.
[
{
"id": "c2883a331c36842f",
"type": "tab",
"label": "OpenAI",
"disabled": false,
"info": "",
"env": []
},
{
"id": "1de2dab24e4aea36",
"type": "function",
"z": "c2883a331c36842f",
"name": "function 1",
"func": "msg.url = \"https://api.openai.com/v1/images/generations\";\nmsg.method = \"POST\";\nvar prompt = msg.payload;\nvar n = 2;\nvar size = \"512x512\";\n\nmsg.payload = {\n \"prompt\": prompt,\n \"n\": n,\n \"size\": size,\n};\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 740,
"y": 200,
"wires": [
[
"b5c4b9a30cd04582"
]
]
},
{
"id": "b5c4b9a30cd04582",
"type": "http request",
"z": "c2883a331c36842f",
"name": "",
"method": "use",
"ret": "obj",
"paytoqs": "ignore",
"url": "",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "bearer",
"senderr": false,
"headers": [],
"x": 950,
"y": 200,
"wires": [
[
"0a851b5ea2c3db75"
]
]
},
{
"id": "af927ae24f9e9018",
"type": "ui_text_input",
"z": "c2883a331c36842f",
"name": "Prompt",
"label": "Enter a Prompt, like \"Paddleboarding with a scarecrow at sunset\"",
"tooltip": "Enter a prompt!",
"group": "dcc461615ad026bf",
"order": 1,
"width": 0,
"height": 0,
"passthru": true,
"mode": "text",
"delay": 300,
"topic": "",
"x": 440,
"y": 120,
"wires": [
[
"b717e2dd116b0935"
]
]
},
{
"id": "7d109687b80b952a",
"type": "ui_button",
"z": "c2883a331c36842f",
"name": "",
"group": "dcc461615ad026bf",
"order": 2,
"width": 0,
"height": 0,
"passthru": false,
"label": "submit",
"tooltip": "",
"color": "",
"bgcolor": "",
"icon": "",
"payload": "prompt",
"payloadType": "flow",
"topic": "",
"x": 470,
"y": 200,
"wires": [
[
"1de2dab24e4aea36"
]
]
},
{
"id": "b717e2dd116b0935",
"type": "change",
"z": "c2883a331c36842f",
"name": "",
"rules": [
{
"t": "set",
"p": "prompt",
"pt": "flow",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 760,
"y": 120,
"wires": [
[]
]
},
{
"id": "0a851b5ea2c3db75",
"type": "ui_template",
"z": "c2883a331c36842f",
"group": "dcc461615ad026bf",
"name": "",
"order": 3,
"width": 0,
"height": 0,
"format": "<div layout=\"row\" layout-align=\"space-between\">\n \n <img src=\"{{msg.payload.data[0].url}}\">\n <img src=\"{{msg.payload.data[1].url}}\">\n\n \n</div>\n\n",
"storeOutMessages": true,
"fwdInMessages": true,
"resendOnRefresh": true,
"templateScope": "local",
"x": 1160,
"y": 200,
"wires": [
[]
]
},
{
"id": "dcc461615ad026bf",
"type": "ui_group",
"name": "OpenAI demo",
"tab": "308f09ba75c30f2f",
"disp": true,
"width": "20",
"collapse": false
},
{
"id": "308f09ba75c30f2f",
"type": "ui_tab",
"name": "OpenAI",
"icon": "dashboard",
"order": 1,
"disabled": false,
"hidden": false
}
]