Gradio Client icon

Gradio Client

Connect to Gradio Spaces and call their API functions

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 send input parameters, including optional file uploads, to a specified function endpoint of a Gradio Space and receive the processed output.

Typical scenarios include:

  • Automating calls to machine learning models hosted on Gradio Spaces.
  • Integrating AI-powered features like text generation, image processing, or speech synthesis into workflows.
  • Testing or invoking custom functions deployed in Gradio Spaces programmatically.

For example, you can call a /predict endpoint on a public space to get model predictions or invoke a private space's function that requires authentication.

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 interact with (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 when using auto-detect mode (e.g., /predict).
API Name (Manual) The function endpoint to call, manually entered when using manual API selection (e.g., /generate_speech).
Input Parameters JSON array or object representing the parameters to pass to the function. Examples:
- Array: ["Hello world", 42, true]
- Object: {"text": "Hello", "value": 42}
File Upload Options Settings for uploading a file as one of the function parameters:
- Enable File Upload: Whether to upload a file.
- 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 (defaults to original).
Advanced Options Additional settings:
- Timeout: Maximum wait time in seconds.
- Session Hash: Identifier for the API call session (auto-generated if empty).
- Return Full Response: Return entire response or just data.
- Retry Attempts: Number of retries 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 item contains:

  • json: The main response data returned from the called Gradio Space function. This typically includes the result of the function call.
  • In case of errors (if "Continue On Fail" is enabled), the output will contain an error message and a success flag set to false.

If binary file upload is used, the node expects the file data in a binary property specified by the user but does not output binary data itself.

Dependencies

  • Requires access to the internet to reach the specified Gradio Space URL.
  • For private spaces, requires a valid HuggingFace API key credential configured in n8n.
  • No other external dependencies are required beyond standard HTTP request capabilities.

Troubleshooting

  • Authentication Errors: If using private spaces, ensure the HuggingFace API key is correctly configured and has necessary permissions. Missing or invalid keys will cause authentication failures.
  • Invalid Space URL: Ensure the Space URL is correct and accessible. Malformed URLs or unreachable spaces will cause request failures.
  • Incorrect API Endpoint: When manually entering the API endpoint, verify the path matches a valid function exposed by the Space.
  • File Upload Issues: Make sure the binary property name matches the actual binary data property in the input. Also, confirm the parameter index corresponds to the expected position in the function parameters.
  • Timeouts: Increase the timeout setting if the Space takes longer to respond.
  • Retry Attempts: Adjust retry attempts for transient network issues.
  • Debug Mode: Enable debug mode to get detailed logs for diagnosing problems.

Common error messages:

  • "HuggingFace API credentials not found or invalid": Check API key configuration.
  • "Unknown operation: ...": Verify the selected operation is supported.
  • Network or HTTP errors: Check connectivity and Space availability.

Links and References

Discussion