Installation
- npm
- CDN
Install via npm for Node.js projects (requires Node.js 18.0.0 or higher):
Quick start
Here’s a simple example using the Whisper transcription Space:Connecting to apps
Connect to Hugging Face Spaces
Connect to a Gradio app by passing the Space name:Connect to private Spaces
For private Spaces, pass your Hugging Face token:Connect to custom URLs
If your app is running on your own server:Connect with authentication
If the app requires username and password:Duplicate a Space for unlimited usage
For unlimited usage without rate limits, duplicate the Space:Configure hardware
Customize the hardware and timeout settings:If the original Space uses GPUs, your duplicated Space will be billed accordingly. Spaces automatically sleep after 5 minutes of inactivity.
Inspect API endpoints
View available endpoints and their parameters:Make predictions
Basic prediction
Call.predict() with the endpoint name and arguments:
Multiple parameters
Pass multiple arguments as an array:File inputs
For file inputs, pass aBuffer, Blob, or File:
Using events
For endpoints that return results over time or for monitoring job status, use the event interface:Monitor status
Enable status updates by setting theevents option:
status: Human-readable status (pending,generating,complete,error)code: Detailed Gradio status codeposition: Position in queuequeue_size: Total queue sizeeta: Estimated completion timesuccess: Whether job completed successfullytime: When status was generated
Cancel jobs
Cancel queued or running jobs:Generator endpoints
For endpoints that yield multiple values, iterate over the results:Cancel generator endpoints
Cancel iterative outputs to stop generation:Complete example
Here’s a complete HTML example:Next steps
Python client
Use Gradio apps as APIs from Python
FastAPI integration
Integrate Gradio client with FastAPI