write me the detailed json file of this n8n workflow , the json file should be suitable…
- User
write me the detailed json file of this n8n workflow , the json file should be suitable with n8n here is the workflow “To implement this in n8n, you can follow these steps:
-
Create a new workflow in n8n.
-
Add an HTTP Request node to send the POST request to create a new prediction. Configure the node as follows:
-
HTTP Request Method: POST
-
Authentication: Add a new credential of type “Headers” with the following key-value pair:
-
Key: Authorization
-
Value: Token <paste-your-token-here>
-
JSON Parameters: Add the following JSON data:
{ “version”: “5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa”, “input”: { “text”: “Alice” } }
-
Add a Function node to parse the response from the previous HTTP Request node and extract the prediction_id from the id property.
-
Add another HTTP Request node to send the GET request to retrieve the prediction status and output. Configure the node as follows:
- HTTP Request Method: GET
- URL: https://api.replicate.com/v1/predictions/{{$node["Function"].json["id"]}}
- Authentication: Same as the previous HTTP Request node
-
Add a Loop node to continuously check the prediction status until it is completed. Connect the Loop node to the second HTTP Request node.
-
Add a Switch node inside the Loop node to check the prediction status. Configure the Switch node with the following rules:
- If the status property is succeeded, the workflow can exit the Loop and proceed to the next step.
- If the status property is failed or canceled, the workflow can exit the Loop and handle the error case.
- If the status property is starting or processing, the workflow should continue looping.
-
Add a Delay node inside the Loop node to introduce a delay (e.g., 5 seconds) between each iteration of the Loop to avoid overwhelming the API with too many requests.
-
Add a final node (e.g., Code node or No Operation node) to handle the successful prediction output or the error case.
By following these steps, you can create an n8n workflow that interacts with the Replicate API to create a prediction, continuously check its status, and retrieve the final output or handle any errors that may occur.
-
- Assistant