Custom Components GalleryNEW
ExploreCustom Components GalleryNEW
ExploreNew to Gradio? Start here: Getting Started
See the Release History
To install Gradio from main, run the following command:
pip install https://gradio-builds.s3.amazonaws.com/a26030d1fa39ffc75ce53d4285caa98eeb1dc13a/gradio-4.32.1-py3-none-any.whl
*Note: Setting share=True
in
launch()
will not work.
gradio_client.Client(···)
from gradio_client import Client
client = Client("abidlabs/whisper-large-v2") # connecting to a Hugging Face Space
client.predict("test.mp4", api_name="/predict")
>> What a nice recording! # returns the result of the remote API call
client = Client("https://bec81a83-5b5c-471e.gradio.live") # connecting to a temporary Gradio share URL
job = client.submit("hello", api_name="/predict") # runs the prediction in a background thread
job.result()
>> 49 # returns the result of the remote API call (blocking call)
Parameter | Description |
---|---|
src str required | Either the name of the Hugging Face Space to load, (e.g. "abidlabs/whisper-large-v2") or the full URL (including "http" or "https") of the hosted Gradio app to load (e.g. "http://mydomain.com/app" or "https://bec81a83-5b5c-471e.gradio.live/"). |
hf_token str | None default: None | The Hugging Face token to use to access private Spaces. Automatically fetched if you are logged in via the Hugging Face Hub CLI. Obtain from: https://huggingface.co/settings/token |
max_workers int default: 40 | The maximum number of thread workers that can be used to make requests to the remote Gradio app simultaneously. |
serialize bool | None default: None | Deprecated. Please use the equivalent |
output_dir str | Path default: "/tmp/gradio" | The directory to save files that are downloaded from the remote API. If None, reads from the GRADIO_TEMP_DIR environment variable. Defaults to a temporary directory on your machine. |
verbose bool default: True | Whether the client should print statements to the console. |
auth tuple[str, str] | None default: None | |
headers dict[str, str] | None default: None | Additional headers to send to the remote Gradio app on every request. By default only the HF authorization and user-agent headers are sent. These headers will override the default headers if they have the same keys. |
upload_files bool default: True | Whether the client should treat input string filepath as files and upload them to the remote server. If False, the client will treat input string filepaths as strings always and not modify them, and files should be passed in explicitly using |
download_files bool default: True | Whether the client should download output files from the remote API and return them as string filepaths on the local machine. If False, the client will return a FileData dataclass object with the filepath on the remote machine instead. |
ssl_verify bool default: True | If False, skips certificate validation which allows the client to connect to Gradio apps that are using self-signed certificates. |
Event listeners allow you to capture and respond to user interactions with the UI components you've defined in a Gradio Blocks app. When a user interacts with an element, such as changing a slider value or uploading an image, a function is called.
The Client component supports the following event listeners. Each event listener takes the same parameters, which are listed in the Event Arguments table below.
Listener | Description |
---|---|
| Calls the Gradio API and returns the result (this is a blocking call). <br> |
| Creates and returns a Job object which calls the Gradio API in a background thread. The job can be used to retrieve the status and result of the remote API call. <br> |
| Prints the usage info for the API. If the Gradio app has multiple API endpoints, the usage info for each endpoint will be printed separately. If return_format="dict" the info is returned in dictionary format, as shown in the example below. <br> |
| Duplicates a Hugging Face Space under your account and returns a Client object for the new Space. No duplication is created if the Space already exists in your account (to override this, provide a new name for the new Space using |
| Deploy the upstream app as a discord bot. Currently only supports gr.ChatInterface. |
Parameter | Description |
---|---|
args <class 'inspect._empty'> required | The arguments to pass to the remote API. The order of the arguments must match the order of the inputs in the Gradio app. |
api_name str | None default: None | The name of the API endpoint to call starting with a leading slash, e.g. "/predict". Does not need to be provided if the Gradio app has only one named API endpoint. |
fn_index int | None default: None | As an alternative to api_name, this parameter takes the index of the API endpoint to call, e.g. 0. Both api_name and fn_index can be provided, but if they conflict, api_name will take precedence. |