Gradio Client icon

Gradio Client

Connect to Gradio Spaces and call their API functions

Overview

This node integrates with Gradio Spaces, allowing users to interact programmatically with Gradio-hosted machine learning models or applications. It supports fetching metadata about a Gradio Space and invoking functions exposed by the Space. This is useful for automating workflows that require AI model inference or data processing hosted on Gradio without manual intervention.

Common scenarios include:

  • Retrieving information about a specific Gradio Space (e.g., description, status).
  • Sending input data to a Gradio app function and receiving processed results.
  • Automating batch processing of inputs through a Gradio-hosted model.

Practical example:

  • Automatically sending images to a Gradio image classification model and collecting labels.
  • Fetching the current status or configuration details of a deployed Gradio Space before triggering further actions.

Properties

Name Meaning
Authentication Choose authentication method:
- None: Public space, no authentication needed.
- HuggingFace API: Private space requiring an API key.
Space URL Full URL of the Gradio Space to connect to (e.g., https://username-spacename.hf.space).
Advanced Options Collection of optional settings:
- Timeout: Maximum wait time in seconds.
- Session Hash: Identifier for the API session; auto-generated if empty.
- Return Full Response: Whether to return the entire API response or just the main data.
- Retry Attempts: Number of retries for failed requests (1-5).
- Debug Mode: Enable detailed logging for troubleshooting.

Output

The node outputs JSON data representing the result of the selected operation:

  • For getSpaceInfo operation: JSON containing metadata about the Gradio Space such as its description, status, or other relevant info returned by the Space's API.
  • For callFunction operation: JSON containing the output from the invoked function within the Gradio Space, typically the processed data or prediction results.

If "Return Full Response" is enabled, the entire API response object is returned instead of just the core data.

The node does not explicitly handle binary data output.

Dependencies

  • Requires access to the internet to communicate with Gradio Spaces.
  • If using private spaces, requires an API key credential for HuggingFace authentication.
  • No additional external libraries beyond those bundled with n8n are required.
  • The user must provide a valid Gradio Space URL.
  • Optional advanced options allow configuring timeout, retry attempts, and debugging.

Troubleshooting

  • Authentication errors: If using private spaces, ensure the API key credential is correctly configured and has necessary permissions.
  • Invalid Space URL: Verify the Space URL is correct and accessible.
  • Timeouts: Increase the timeout setting if requests take longer than expected.
  • Retries: Adjust retry attempts if transient network issues occur.
  • Unknown operation error: Ensure the operation parameter is set to either "getSpaceInfo" or "callFunction".
  • Debug mode: Enable debug mode to get detailed logs which can help identify request/response issues.

Links and References

Discussion