Erstellung von AI Bildern mit DALL-E-3 Modell
Die Erstellung von AI Bildern mit DALL-E-3 Modell mit ChatGPT-35 ist über die API Schnittstelle günstiger als ein ChatGPT-4 Account einzurichten und dort monatlich 20 Dollar dafür zu bezahlen.
Deinen API Key erhälst Du über diese Webseite:
https://platform.openai.com/account/api-keys
Dort hab ich einen "Pay As You go" Tarif ausgewählt.
Bilder einfach mit curl erstellen:
export OPENAI_API_KEY=sk-XXXXXDein-API-Key
curl https://api.openai.com/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "dall-e-3",
"prompt": "A cute baby sea otter",
"n": 1,
"size": "1024x1024"
}'
Bilder erstellen mit Python :
pip install openai
Das Ergebnis wird dann als JSON ausgeben , dort den Tag "URL" herauskopieren
Bidler erstellen mit NodeRED:
Achtung : Zeile 81 eigenen API Key eintragen und beginnt mit "sk-XXX"
NodeRED Code bitte anklicken
[
{
"id": "e330b43c654ab038",
"type": "tab",
"label": "Flow 3",
"disabled": false,
"info": "",
"env": []
},
{
"id": "7086e0f63db3332d",
"type": "inject",
"z": "e330b43c654ab038",
"name": "Cute Baby",
"props": [
{
"p": "question",
"v": " a cute baby sea otter",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 120,
"y": 180,
"wires": [
[
"c1cc057222a4ec88"
]
]
},
{
"id": "c1cc057222a4ec88",
"type": "function",
"z": "e330b43c654ab038",
"name": "DALL-E-3 Create Image",
"func": "msg.payload = {\n \"model\": \"dall-e-3\",\n \"prompt\": msg.question,\n \"n\": 1,\n \"size\": \"1024x1024\",\n \"response_format\":\"url\"\n}\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 370,
"y": 180,
"wires": [
[
"42afba693598e446"
]
]
},
{
"id": "42afba693598e446",
"type": "http request",
"z": "e330b43c654ab038",
"name": "API Image",
"method": "POST",
"ret": "obj",
"paytoqs": "ignore",
"url": "https://api.openai.com/v1/images/generations",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [
{
"keyType": "other",
"keyValue": "Content-Type",
"valueType": "other",
"valueValue": "application/json"
},
{
"keyType": "other",
"keyValue": "Authorization",
"valueType": "other",
"valueValue": "Bearer sk-XXXXX"
}
],
"x": 590,
"y": 180,
"wires": [
[
"8f6b829af0ca37de",
"7441d16059efdc2b"
]
]
},
{
"id": "7441d16059efdc2b",
"type": "change",
"z": "e330b43c654ab038",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload.data[0].url",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 790,
"y": 220,
"wires": [
[
"db3a937d89d66f7b",
"6855263aa73b2501"
]
]
},
{
"id": "db3a937d89d66f7b",
"type": "image",
"z": "e330b43c654ab038",
"name": "",
"width": "500",
"data": "payload",
"dataType": "msg",
"thumbnail": false,
"active": true,
"pass": false,
"outputs": 0,
"x": 400,
"y": 320,
"wires": []
},
{
"id": "8f6b829af0ca37de",
"type": "debug",
"z": "e330b43c654ab038",
"name": "Debug",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 750,
"y": 180,
"wires": []
},
{
"id": "ca1eb1e42d901944",
"type": "inject",
"z": "e330b43c654ab038",
"name": "Michael Jordan",
"props": [
{
"p": "question",
"v": "Michael Jordan can't dunk in realistic style.",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 140,
"y": 220,
"wires": [
[
"c1cc057222a4ec88"
]
]
},
{
"id": "6855263aa73b2501",
"type": "ui_template",
"z": "e330b43c654ab038",
"group": "0471b7a87c9146b9",
"name": "Display Picture on Dashboard",
"order": 0,
"width": "12",
"height": "12",
"format": "<img ng-src=\"{{msg.payload}}\" alt=\"Bildbeschreibung\">",
"storeOutMessages": true,
"fwdInMessages": true,
"resendOnRefresh": true,
"templateScope": "local",
"className": "",
"x": 1070,
"y": 220,
"wires": [
[]
]
},
{
"id": "0471b7a87c9146b9",
"type": "ui_group",
"name": "OPENAI Group",
"tab": "800ecd05c740fe27",
"order": 1,
"disp": true,
"width": "12",
"collapse": false,
"className": ""
},
{
"id": "800ecd05c740fe27",
"type": "ui_tab",
"name": "OpenAI ",
"icon": "dashboard",
"order": 10,
"disabled": false,
"hidden": false
}
]
Ansicht im Dashboard :