94 lines
2.4 KiB
JSON
94 lines
2.4 KiB
JSON
|
|
{
|
||
|
|
"name": "Gerador de Imagens (GPT-Image-2)",
|
||
|
|
"nodes": [
|
||
|
|
{
|
||
|
|
"parameters": {
|
||
|
|
"httpMethod": "POST",
|
||
|
|
"path": "generate-ad-image",
|
||
|
|
"responseMode": "lastNode",
|
||
|
|
"options": {}
|
||
|
|
},
|
||
|
|
"id": "webhook-node-1",
|
||
|
|
"name": "Webhook",
|
||
|
|
"type": "n8n-nodes-base.webhook",
|
||
|
|
"typeVersion": 1,
|
||
|
|
"position": [
|
||
|
|
250,
|
||
|
|
300
|
||
|
|
],
|
||
|
|
"webhookId": "ad-image-generator"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"parameters": {
|
||
|
|
"method": "POST",
|
||
|
|
"url": "https://api.openai.com/v1/images/generations",
|
||
|
|
"sendHeaders": true,
|
||
|
|
"headerParameters": {
|
||
|
|
"parameters": [
|
||
|
|
{
|
||
|
|
"name": "Authorization",
|
||
|
|
"value": "Bearer sk-proj-COLOQUE_SUA_CHAVE_AQUI"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"name": "Content-Type",
|
||
|
|
"value": "application/json"
|
||
|
|
}
|
||
|
|
]
|
||
|
|
},
|
||
|
|
"sendBody": true,
|
||
|
|
"specifyBody": "json",
|
||
|
|
"jsonBody": "={\n \"model\": \"gpt-image-2\",\n \"prompt\": \"{{ $json.body.prompt }}\",\n \"n\": 1,\n \"size\": \"{{ $json.body.dimensions || '1024x1024' }}\"\n}",
|
||
|
|
"options": {
|
||
|
|
"timeout": 120000
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"id": "http-request-1",
|
||
|
|
"name": "OpenAI - Generate Image",
|
||
|
|
"type": "n8n-nodes-base.httpRequest",
|
||
|
|
"typeVersion": 4.1,
|
||
|
|
"position": [
|
||
|
|
450,
|
||
|
|
300
|
||
|
|
]
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"parameters": {
|
||
|
|
"jsCode": "const response = $input.first().json;\n\n// Pega a URL ou o Base64 gerado pela OpenAI\nlet imageUrl = response.data?.[0]?.url;\nif (!imageUrl && response.data?.[0]?.b64_json) {\n imageUrl = `data:image/png;base64,${response.data[0].b64_json}`;\n}\n\n// Devolve o JSON no formato que o Next.js espera\nreturn {\n url: imageUrl,\n revised_prompt: response.data?.[0]?.revised_prompt || \"\"\n};"
|
||
|
|
},
|
||
|
|
"id": "code-node-1",
|
||
|
|
"name": "Format Output",
|
||
|
|
"type": "n8n-nodes-base.code",
|
||
|
|
"typeVersion": 2,
|
||
|
|
"position": [
|
||
|
|
650,
|
||
|
|
300
|
||
|
|
]
|
||
|
|
}
|
||
|
|
],
|
||
|
|
"connections": {
|
||
|
|
"Webhook": {
|
||
|
|
"main": [
|
||
|
|
[
|
||
|
|
{
|
||
|
|
"node": "OpenAI - Generate Image",
|
||
|
|
"type": "main",
|
||
|
|
"index": 0
|
||
|
|
}
|
||
|
|
]
|
||
|
|
]
|
||
|
|
},
|
||
|
|
"OpenAI - Generate Image": {
|
||
|
|
"main": [
|
||
|
|
[
|
||
|
|
{
|
||
|
|
"node": "Format Output",
|
||
|
|
"type": "main",
|
||
|
|
"index": 0
|
||
|
|
}
|
||
|
|
]
|
||
|
|
]
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"settings": {}
|
||
|
|
}
|