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 retrieving information about a specific Gradio Space and calling functions exposed by that Space.

Common scenarios include:

  • Automating calls to ML models hosted on Gradio Spaces for predictions or data processing.
  • Fetching metadata or status information about a Gradio Space.
  • Integrating Gradio-hosted services into larger workflows without manual intervention.

Practical example:

  • A user wants to send text input to a sentiment analysis model hosted on a Gradio Space and receive the sentiment score as output.
  • Another use case is monitoring a Space’s availability or configuration by fetching its info regularly.

Properties

Name Meaning
Authentication Choose authentication method:
- None: Public space, no authentication needed.
- HuggingFace API: Private space requiring an API key credential.
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 call session; auto-generated if empty.
- Return Full Response: Whether to return the complete API response or just the main data.
- Retry Attempts: Number of retry attempts for failed requests (1-5).
- Debug Mode: Enable detailed logging for troubleshooting.

Output

The node outputs JSON data representing either:

  • The information about the Gradio Space (when using the "getSpaceInfo" operation).
  • The result of calling a function on the Gradio Space (when using the "callFunction" operation).

If the "Return Full Response" option is enabled, the entire API response is returned; otherwise, only the core data is provided.

No binary data output is indicated by the source code.

Dependencies

  • Requires access to the internet to communicate with Gradio Spaces via their public URLs.
  • If using private Spaces, an API key credential for HuggingFace authentication must be configured in n8n.
  • No other external dependencies are explicitly required.

Troubleshooting

  • Missing or invalid API key: If the node is set to use HuggingFace API authentication but credentials are missing or invalid, it throws an error indicating the absence or invalidity of the API key. Solution: Ensure the API key credential is correctly set up in n8n.
  • Unknown operation error: If an unsupported operation is selected, the node will throw an error stating "Unknown operation". Solution: Use only supported operations ("getSpaceInfo" or "callFunction").
  • Timeouts or network errors: Requests may fail due to network issues or long response times. Adjust the "Timeout" and "Retry Attempts" advanced options accordingly.
  • Debug mode: Enabling debug mode provides detailed logs which can help diagnose issues related to request formation or responses.

Links and References

Discussion