Actions2
Overview
This node allows users to interact with Gradio Spaces by calling functions exposed via their API endpoints. It supports both public (no authentication) and private spaces requiring HuggingFace API authentication. The primary use case is to invoke a function on a Gradio Space, passing input parameters and optionally uploading files as part of the request.
Typical scenarios include:
- Automating calls to machine learning models hosted on Gradio Spaces.
- Integrating AI-powered features from Gradio Spaces into workflows.
- Sending complex inputs including files to Gradio Spaces for processing.
For example, you might call a text generation model's /predict endpoint with a prompt string or upload an image file to an image classification model.
Properties
| Name | Meaning |
|---|---|
| Authentication | Choose the authentication method: - None: Public space, no authentication needed. - HuggingFace API: Private space requiring HuggingFace API key authentication. |
| Space URL | Full URL of the Gradio Space to call, e.g., https://username-spacename.hf.space. |
| API Selection | How to select the API endpoint: - Auto-detect from Space: Automatically load available function endpoints. - Manual Entry: Manually specify the function endpoint path. |
| API Name | The function endpoint to call, selected automatically from the Space (e.g., /predict). Only shown if API Selection is "Auto-detect". |
| API Name (Manual) | The function endpoint to call, manually entered (e.g., /predict, /generate_speech). Only shown if API Selection is "Manual Entry". |
| Input Parameters | JSON array of parameters to pass to the function. Must be a valid JSON array, e.g., ["Hello world", 42, true]. |
| File Upload Options | Collection of options to enable uploading a file as one of the function parameters: - Enable File Upload: Toggle file upload. - Parameter Index: Which parameter index to replace with the file (0-based). - File Property Name: Binary property name containing the file. - Filename: Optional filename to use when uploading; leave empty to use original. |
| Advanced Options | Additional settings: - Timeout: Maximum wait time in seconds. - Session Hash: Session identifier for the API call; auto-generated if empty. - Return Full Response: Whether to return the complete response or just the data. - Retry Attempts: Number of retry attempts for failed requests (1-5). - Debug Mode: Enable detailed logging for troubleshooting. |
Output
The node outputs an array of JSON objects corresponding to each input item processed. Each output JSON contains the response data returned from the called Gradio Space function.
- If Return Full Response is enabled, the entire API response is returned.
- Otherwise, only the main data portion of the response is output.
- In case of errors (and if "Continue On Fail" is enabled), the output includes an error message and a success flag set to false.
- The node can handle binary file uploads but does not output binary data itself; it only sends files as input parameters.
Dependencies
- Requires access to the specified Gradio Space URL.
- For private spaces, requires a valid HuggingFace API key credential configured in n8n.
- Uses standard HTTP headers including
Authorizationwhen authenticated. - No other external dependencies beyond the Gradio Space API.
Troubleshooting
- Authentication Errors: If using HuggingFace API authentication, ensure the API key credential is correctly configured and has necessary permissions.
- Invalid Space URL: Verify the Space URL is correct and accessible.
- Malformed Input Parameters: Input parameters must be a valid JSON array; invalid JSON will cause errors.
- File Upload Issues: Ensure the binary property name matches the actual binary data in the input. Also, verify the parameter index corresponds to the intended function argument.
- Timeouts: Increase the timeout setting if the Space takes longer to respond.
- API Endpoint Not Found: When using auto-detect, if the desired function is missing, try manual entry of the API endpoint.
- Retry Attempts: Adjust retry attempts if transient network errors occur.
Common error messages typically indicate missing credentials, invalid URLs, or malformed input parameters. Enabling debug mode provides detailed logs to help diagnose issues.