{
  "meta": {
    "model_name": "granite-vision-3.3-2b",
    "model_type": "image",
    "version_id": "3339e8453ca94104383f6f085a511d7f26cca2d0cab2f6018986737b6cf7d391",
    "model_owner": "ibm-granite",
    "generated_at": "2025-08-01T14:50:46.652195"
  },
  "name": "ibm-granite/granite-vision-3.3-2b - Image Generator",
  "nodes": [
    {
      "id": "ec2ba6e1-953d-4cc2-a07d-007aaf83d339",
      "name": "Manual Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -896,
        -176
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "cf198ceb-fee9-4b65-a3d6-7c32aa5e3bc7",
      "name": "Set API Token",
      "type": "n8n-nodes-base.set",
      "position": [
        -608,
        -80
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "api_token",
              "name": "api_token",
              "type": "string",
              "value": "YOUR_REPLICATE_API_TOKEN"
            }
          ]
        }
      },
      "typeVersion": 3.3
    },
    {
      "id": "fb94b5a3-8820-409e-ace6-94ad60801dcf",
      "name": "Set Image Parameters",
      "type": "n8n-nodes-base.set",
      "position": [
        -288,
        -128
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "api_token",
              "name": "api_token",
              "type": "string",
              "value": "={{ $('Set API Token').item.json.api_token }}"
            },
            {
              "id": "seed",
              "name": "seed",
              "type": "number",
              "value": -1
            },
            {
              "id": "image",
              "name": "image",
              "type": "string",
              "value": "https://picsum.photos/512/512"
            },
            {
              "id": "top_k",
              "name": "top_k",
              "type": "number",
              "value": 50
            },
            {
              "id": "top_p",
              "name": "top_p",
              "type": "number",
              "value": 0.9
            },
            {
              "id": "images",
              "name": "images",
              "type": "array",
              "value": ""
            },
            {
              "id": "prompt",
              "name": "prompt",
              "type": "string",
              "value": ""
            },
            {
              "id": "max_tokens",
              "name": "max_tokens",
              "type": "number",
              "value": 512
            },
            {
              "id": "min_tokens",
              "name": "min_tokens",
              "type": "number",
              "value": 0
            },
            {
              "id": "temperature",
              "name": "temperature",
              "type": "number",
              "value": 0.6
            },
            {
              "id": "chat_template",
              "name": "chat_template",
              "type": "string",
              "value": ""
            },
            {
              "id": "system_prompt",
              "name": "system_prompt",
              "type": "string",
              "value": ""
            },
            {
              "id": "stop_sequences",
              "name": "stop_sequences",
              "type": "string",
              "value": ""
            },
            {
              "id": "presence_penalty",
              "name": "presence_penalty",
              "type": "number",
              "value": 0
            },
            {
              "id": "frequency_penalty",
              "name": "frequency_penalty",
              "type": "number",
              "value": 0
            }
          ]
        }
      },
      "typeVersion": 3.3
    },
    {
      "id": "afa98553-a5f7-481e-8e34-3e185118fce6",
      "name": "Create Image Prediction",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -64,
        -128
      ],
      "parameters": {
        "url": "https://api.replicate.com/v1/predictions",
        "method": "POST",
        "options": {
          "response": {
            "response": {
              "neverError": true,
              "responseFormat": "json"
            }
          }
        },
        "jsonBody": "={\n  \"version\": \"ibm-granite/granite-vision-3.3-2b:3339e8453ca94104383f6f085a511d7f26cca2d0cab2f6018986737b6cf7d391\",\n  \"input\": {\n    \"seed\": {{ $json.seed }},\n    \"image\": \"{{ $json.image }}\",\n    \"top_k\": {{ $json.top_k }},\n    \"top_p\": {{ $json.top_p }},\n    \"images\": \"{{ $json.images }}\",\n    \"prompt\": \"{{ $json.prompt }}\",\n    \"max_tokens\": {{ $json.max_tokens }},\n    \"min_tokens\": {{ $json.min_tokens }},\n    \"temperature\": {{ $json.temperature }},\n    \"chat_template\": \"{{ $json.chat_template }}\",\n    \"system_prompt\": \"{{ $json.system_prompt }}\",\n    \"stop_sequences\": \"{{ $json.stop_sequences }}\",\n    \"presence_penalty\": {{ $json.presence_penalty }},\n    \"frequency_penalty\": {{ $json.frequency_penalty }}\n  }\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $json.api_token }}"
            },
            {
              "name": "Prefer",
              "value": "wait"
            }
          ]
        }
      },
      "typeVersion": 4.1
    },
    {
      "id": "7a54179b-cd9a-4fb4-860c-2d0202442728",
      "name": "Wait 5s",
      "type": "n8n-nodes-base.wait",
      "position": [
        160,
        -128
      ],
      "parameters": {
        "unit": "seconds",
        "amount": 5
      },
      "typeVersion": 1
    },
    {
      "id": "3b276bd4-5192-4e9f-8237-7236b8381777",
      "name": "Check Status",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        384,
        -128
      ],
      "parameters": {
        "url": "=https://api.replicate.com/v1/predictions/{{ $('Create Image Prediction').item.json.id }}",
        "options": {
          "response": {
            "response": {
              "neverError": true,
              "responseFormat": "json"
            }
          }
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('Set API Token').item.json.api_token }}"
            }
          ]
        }
      },
      "typeVersion": 4.1
    },
    {
      "id": "180685c9-642b-4541-972f-1b2cffc2dffe",
      "name": "Is Complete?",
      "type": "n8n-nodes-base.if",
      "position": [
        528,
        -240
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 1,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "c93d7ba1-0ef9-4087-aa10-389cb2a2c6bd",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "succeeded"
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "74634644-1e7a-4e47-8970-389f0b958867",
      "name": "Has Failed?",
      "type": "n8n-nodes-base.if",
      "position": [
        848,
        -80
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 1,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "d1bfd044-3a07-4c18-b55f-72d192596139",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "failed"
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "e78a79a9-2985-47c4-aca5-7701e783ef95",
      "name": "Wait 10s",
      "type": "n8n-nodes-base.wait",
      "position": [
        720,
        128
      ],
      "parameters": {
        "unit": "seconds",
        "amount": 10
      },
      "typeVersion": 1
    },
    {
      "id": "6a09a147-68fb-4639-b754-ad248c0ebc20",
      "name": "Success Response",
      "type": "n8n-nodes-base.set",
      "position": [
        832,
        -320
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "success-response",
              "name": "response",
              "type": "object",
              "value": "={{ { success: true, image_url: $json.output, prediction_id: $json.id, status: $json.status, message: 'Image generated successfully' } }}"
            }
          ]
        }
      },
      "typeVersion": 3.3
    },
    {
      "id": "2cb820fb-6f11-43e6-8d98-bb83a110b48d",
      "name": "Error Response",
      "type": "n8n-nodes-base.set",
      "position": [
        1344,
        144
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "error-response",
              "name": "response",
              "type": "object",
              "value": "={{ { success: false, error: $json.error || 'Image generation failed', prediction_id: $json.id, status: $json.status, message: 'Failed to generate image' } }}"
            }
          ]
        }
      },
      "typeVersion": 3.3
    },
    {
      "id": "24a36c6c-de77-4761-8cdd-211caf66f58b",
      "name": "Display Result",
      "type": "n8n-nodes-base.set",
      "position": [
        1552,
        -144
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "final-result",
              "name": "final_result",
              "type": "object",
              "value": "={{ $json.response }}"
            }
          ]
        }
      },
      "typeVersion": 3.3
    },
    {
      "id": "bb77c5c2-aedf-4aa5-9e3d-211f500e507f",
      "name": "Log Request",
      "type": "n8n-nodes-base.code",
      "position": [
        160,
        -320
      ],
      "parameters": {
        "jsCode": "// Log generation details for monitoring\nconst data = $input.all()[0].json;\n\nconsole.log('ibm-granite/granite-vision-3.3-2b Request:', {\n  timestamp: new Date().toISOString(),\n  prediction_id: data.id,\n  model_type: 'image'\n});\n\nreturn $input.all();"
      },
      "typeVersion": 2
    },
    {
      "id": "b74552b8-11f7-4d40-9dd7-7e712157b299",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1536,
        -304
      ],
      "parameters": {
        "color": 4,
        "width": 580,
        "height": 320,
        "content": "=======================================\n        GRANITE-VISION-3.3-2B GENERATOR\n=======================================\nFor any questions or support, please contact:\n    Yaron@nofluff.online\n\nExplore more tips and tutorials here:\n   - YouTube: https://www.youtube.com/@YaronBeen/videos\n   - LinkedIn: https://www.linkedin.com/in/yaronbeen/\n======================================="
      },
      "typeVersion": 1
    },
    {
      "id": "8ce498b4-8551-461b-9d91-f23dbbb4bf51",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1536,
        48
      ],
      "parameters": {
        "color": 4,
        "width": 589,
        "height": 1958,
        "content": "## \ud83e\udd16 **IBM-GRANITE/GRANITE-VISION-3.3-2B - IMAGE GENERATION WORKFLOW**\n\n**\ud83d\udd25 Powered by Replicate API and n8n Automation**\n\n---\n\n### \ud83d\udcdd **Model Overview**\n\n- **Owner**: ibm-granite\n- **Model**: granite-vision-3.3-2b\n- **Type**: Image Generation\n- **API Endpoint**: https://api.replicate.com/v1/predictions\n\n**\ud83c\udfaf What This Model Does:**\nGranite-vision-3.3-2b is a compact and efficient vision-language model, specifically designed for visual document understanding, enabling automated content extraction from tables, charts, infographics, plots, diagrams, and more.\n\n---\n\n### \ud83d\udccb **Parameter Reference**\n\n**\ud83d\udd34 Required Parameters:** None\n**\ud83d\udd35 Optional Parameters:** seed, image, top_k, top_p, images, prompt, max_tokens, min_tokens (and 6 more)\n\n**\ud83d\udcd6 Detailed Parameter Guide:**\n- **seed** (integer): Random seed. Leave blank to randomize the seed.\n- **image** (string): Deprecated single image input.Use images input instead.Ignored if images used.\n- **top_k** (integer): The number of highest probability tokens to consider for generating the output. If > 0, only keep... (Default: 50)\n- **top_p** (number): A probability threshold for generating the output. If < 1.0, only keep the top tokens with cumula... (Default: 0.9)\n- **images** (array): Image inputs for the model.\n- **prompt** (string): User prompt to send to the model. (Default: )\n- **max_tokens** (integer): The maximum number of tokens the model should generate as output. (Default: 512)\n- **min_tokens** (integer): The minimum number of tokens the model should generate as output. (Default: 0)\n- *...and 6 more parameters*\n\n---\n\n### \ud83d\udd27 **Workflow Components Explained**\n\n**\ud83c\udfaf Manual Trigger**\n- Starts the workflow execution\n- Click to begin image generation process\n\n**\ud83d\udd10 Set API Token** \n- Configures your Replicate API authentication\n- Replace 'YOUR_REPLICATE_API_TOKEN' with your actual token\n- Essential for accessing the ibm-granite/granite-vision-3.3-2b model\n\n**\u2699\ufe0f Set Image Parameters**\n- Configures all input parameters for the model\n- Includes both required and optional parameters\n- Pre-filled with sensible defaults for testing\n\n**\ud83d\ude80 Create Image Prediction**\n- Sends the generation request to Replicate API\n- Uses the image parameters you configured\n- Returns a prediction ID for status tracking\n\n**\u23f3 Wait & Status Checking Loop**\n- Waits 5 seconds then checks prediction status\n- Continues checking until completion or failure\n- Implements intelligent retry logic with 10-second delays\n\n**\u2705 Success/Error Handling**\n- Routes successful completions to success response\n- Handles failures gracefully with error details\n- Returns structured JSON response with URLs/errors\n\n**\ud83d\udcca Logging & Monitoring**\n- Logs all requests for debugging and monitoring\n- Tracks timestamps and prediction IDs\n- Helps identify issues during development\n\n---\n\n### \ud83c\udf1f **Key Benefits**\n\n- **\ud83c\udfa8 Instant Image Generation**: Transform ideas into images using state-of-the-art AI\n- **\ud83d\udd04 Automated Workflow**: Handles the complete generation pipeline automatically\n- **\ud83d\udee1\ufe0f Error Resilience**: Built-in retry logic and comprehensive error handling\n- **\ud83d\udcc8 Production Ready**: Includes logging, monitoring, and structured responses\n- **\ud83d\udd27 Customizable**: Easy to modify parameters and extend functionality\n- **\u26a1 Efficient Processing**: Optimized API calls with intelligent status checking\n\n---\n\n### \ud83d\ude80 **Quick Start Instructions**\n\n1. **\ud83d\udd11 Get Your API Key**\n   - Sign up at https://replicate.com\n   - Navigate to your account settings\n   - Copy your API token\n\n2. **\ud83d\udd27 Configure the Workflow**\n   - Replace 'YOUR_REPLICATE_API_TOKEN' with your actual token\n   - Adjust parameters in the 'Set Image Parameters' node\n   - Customize the prompt or other inputs as needed\n\n3. **\u25b6\ufe0f Execute the Workflow**\n   - Click the 'Manual Trigger' to start\n   - Monitor the execution in the n8n interface\n   - Check logs for detailed execution information\n\n4. **\ud83d\udce5 Get Your Results**\n   - Successful generations return a URL to your image\n   - Download or use the generated content as needed\n   - Results are available immediately upon completion\n\n---\n\n### \ud83d\udd0d **Troubleshooting Guide**\n\n**Common Issues:**\n- **Invalid API Token**: Ensure your Replicate token is valid and has sufficient credits\n- **Parameter Validation**: Check that required parameters match expected types\n- **Generation Timeout**: Some images take longer - monitor the logs\n- **Output Format**: Verify the model returns the expected output format\n\n**Best Practices:**\n- Test with default parameters first\n- Monitor your Replicate usage and billing\n- Keep API tokens secure and never commit them to code\n- Use appropriate parameter values for your use case\n\n---\n\n**\ud83d\udd17 Additional Resources:**\n- Model Documentation: https://replicate.com/ibm-granite/granite-vision-3.3-2b\n- Replicate API Docs: https://replicate.com/docs\n- n8n Documentation: https://docs.n8n.io\n\n---"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "versionId": "1",
  "connections": {
    "Wait 5s": {
      "main": [
        [
          {
            "node": "Check Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 10s": {
      "main": [
        [
          {
            "node": "Check Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has Failed?": {
      "main": [
        [
          {
            "node": "Error Response",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait 10s",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Request": {
      "main": [
        [
          {
            "node": "Wait 5s",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Status": {
      "main": [
        [
          {
            "node": "Is Complete?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Complete?": {
      "main": [
        [
          {
            "node": "Success Response",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Has Failed?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set API Token": {
      "main": [
        [
          {
            "node": "Set Image Parameters",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Error Response": {
      "main": [
        [
          {
            "node": "Display Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Manual Trigger": {
      "main": [
        [
          {
            "node": "Set API Token",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Success Response": {
      "main": [
        [
          {
            "node": "Display Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Image Parameters": {
      "main": [
        [
          {
            "node": "Create Image Prediction",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Image Prediction": {
      "main": [
        [
          {
            "node": "Log Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}