Replicate icon

Replicate

Use Replicate API

Overview

This node integrates with the Replicate API to run machine learning model predictions. It allows users to specify a model by name and version, provide input properties for the prediction, and then executes the prediction request on Replicate's platform. The node waits for the prediction to complete by polling the API and returns the prediction results.

Common scenarios where this node is beneficial include:

  • Automating AI/ML inference workflows within n8n without manual API calls.
  • Integrating custom or third-party ML models hosted on Replicate into broader automation pipelines.
  • Running batch predictions by feeding multiple inputs through n8n.

Practical example:

  • A user wants to generate image captions using a specific version of an image captioning model hosted on Replicate. They configure the node with the model name, select the desired version, provide the image URL as an input property, and receive the generated caption in the output.

Properties

Name Meaning
Model Name The full identifier of the model to run, typically in the format account/model-name.
Model Version The specific version of the model to use for prediction. Selectable from available versions.
Properties Key-value pairs representing the input parameters for the model prediction. Each property includes:
- Key Name or ID: The input parameter name or ID.
- Type: The data type of the input (boolean, number, string).
- Boolean: Value if type is boolean.
- Number: Value if type is number or integer.
- String: Value if type is string.

Output

The node outputs JSON data representing the prediction result returned by the Replicate API. This includes all fields provided by the API response after the prediction completes successfully.

If the prediction involves binary data (e.g., images), the node does not explicitly handle binary output but provides URLs or references in the JSON output that can be used to fetch such data externally.

Dependencies

  • Requires an API key credential for authenticating with the Replicate API.
  • Needs network access to https://api.replicate.com.
  • Uses internal helper methods for authenticated HTTP requests and metadata construction.
  • The node dynamically loads model versions and input properties via API calls to Replicate.

Troubleshooting

  • No get url found in response: Indicates the prediction response did not include a URL to poll for results. Verify the model name and version are correct and that the API is responding properly.
  • Error getting data from replicate: Occurs when polling the prediction status fails repeatedly. Could be due to network issues or API rate limits. Retry or check API credentials.
  • Prediction failed: The prediction job itself failed on Replicate's side. Check the input properties for correctness and ensure the model supports the given inputs.
  • Long polling times: The node polls every 5 seconds and retries up to 3 times on errors. If predictions take too long, consider increasing timeout settings or checking model performance.

Links and References

Discussion