gradio-client 1.13.3


pip install gradio-client

  Latest version

Released: Sep 26, 2025

Project Links

Meta
Author: Abubakar Abid, Ali Abid, Ali Abdalla, Dawood Khan, Ahsen Khaliq, Pete Allen, Freddy Boulton
Requires Python: >=3.10

Classifiers

Development Status
  • 4 - Beta

License
  • OSI Approved :: Apache Software License

Operating System
  • OS Independent

Programming Language
  • Python :: 3
  • Python :: 3 :: Only
  • Python :: 3.8
  • Python :: 3.9
  • Python :: 3.10
  • Python :: 3.11

Topic
  • Scientific/Engineering
  • Scientific/Engineering :: Artificial Intelligence
  • Software Development :: User Interfaces

gradio_client: Use a Gradio app as an API -- in 3 lines of Python

This directory contains the source code for gradio_client, a lightweight Python library that makes it very easy to use any Gradio app as an API.

As an example, consider this Hugging Face Space that transcribes audio files that are recorded from the microphone.

Using the gradio_client library, we can easily use the Gradio as an API to transcribe audio files programmatically.

Here's the entire code to do it:

from gradio_client import Client

client = Client("abidlabs/whisper")
client.predict("audio_sample.wav")

>> "This is a test of the whisper speech recognition model."

The Gradio client works with any Gradio Space, whether it be an image generator, a stateful chatbot, or a tax calculator.

Installation

If you already have a recent version of gradio, then the gradio_client is included as a dependency.

Otherwise, the lightweight gradio_client package can be installed from pip (or pip3) and works with Python versions 3.10 or higher:

$ pip install gradio_client

Basic Usage

Connecting to a Space or a Gradio app

Start by connecting instantiating a Client object and connecting it to a Gradio app that is running on Spaces (or anywhere else)!

Connecting to a Space

from gradio_client import Client

client = Client("abidlabs/en2fr")  # a Space that translates from English to French

You can also connect to private Spaces by passing in your HF token with the hf_token parameter. You can get your HF token here: https://huggingface.co/settings/tokens

from gradio_client import Client

client = Client("abidlabs/my-private-space", hf_token="...")

Duplicating a Space for private use

While you can use any public Space as an API, you may get rate limited by Hugging Face if you make too many requests. For unlimited usage of a Space, simply duplicate the Space to create a private Space, and then use it to make as many requests as you'd like!

The gradio_client includes a class method: Client.duplicate() to make this process simple:

from gradio_client import Client

client = Client.duplicate("abidlabs/whisper")
client.predict("audio_sample.wav")

>> "This is a test of the whisper speech recognition model."

If you have previously duplicated a Space, re-running duplicate() will not create a new Space. Instead, the Client will attach to the previously-created Space. So it is safe to re-run the Client.duplicate() method multiple times.

Note: if the original Space uses GPUs, your private Space will as well, and your Hugging Face account will get billed based on the price of the GPU. To minimize charges, your Space will automatically go to sleep after 1 hour of inactivity. You can also set the hardware using the hardware parameter of duplicate().

Connecting a general Gradio app

If your app is running somewhere else, just provide the full URL instead, including the "http://" or "https://". Here's an example of making predictions to a Gradio app that is running on a share URL:

from gradio_client import Client

client = Client("https://bec81a83-5b5c-471e.gradio.live")

Inspecting the API endpoints

Once you have connected to a Gradio app, you can view the APIs that are available to you by calling the .view_api() method. For the Whisper Space, we see the following:

Client.predict() Usage Info
---------------------------
Named API endpoints: 1

 - predict(input_audio, api_name="/predict") -> value_0
    Parameters:
     - [Audio] input_audio: str (filepath or URL)
    Returns:
     - [Textbox] value_0: str (value)

This shows us that we have 1 API endpoint in this space, and shows us how to use the API endpoint to make a prediction: we should call the .predict() method, providing a parameter input_audio of type str, which is a filepath or URL.

We should also provide the api_name='/predict' argument. Although this isn't necessary if a Gradio app has a single named endpoint, it does allow us to call different endpoints in a single app if they are available. If an app has unnamed API endpoints, these can also be displayed by running .view_api(all_endpoints=True).

Making a prediction

The simplest way to make a prediction is simply to call the .predict() function with the appropriate arguments:

from gradio_client import Client

client = Client("abidlabs/en2fr")
client.predict("Hello")

>> Bonjour

If there are multiple parameters, then you should pass them as separate arguments to .predict(), like this:

from gradio_client import Client

client = Client("gradio/calculator")
client.predict(4, "add", 5)

>> 9.0

For certain inputs, such as images, you should pass in the filepath or URL to the file. Likewise, for the corresponding output types, you will get a filepath or URL returned.

from gradio_client import Client

client = Client("abidlabs/whisper")
client.predict("https://audio-samples.github.io/samples/mp3/blizzard_unconditional/sample-0.mp3")

>> "My thought I have nobody by a beauty and will as you poured. Mr. Rochester is serve in that so don't find simpus, and devoted abode, to at might in a r—"

Advanced Usage

For more ways to use the Gradio Python Client, check out our dedicated Guide on the Python client, available here: https://www.gradio.app/guides/getting-started-with-the-python-client

2.0.0.dev0 Oct 13, 2025
1.13.3 Sep 26, 2025
1.13.2 Sep 23, 2025
1.13.1 Sep 19, 2025
1.13.0 Sep 10, 2025
1.12.1 Aug 19, 2025
1.12.0 Aug 19, 2025
1.11.1 Aug 08, 2025
1.11.0 Jul 17, 2025
1.10.4 Jun 27, 2025
1.10.3 Jun 10, 2025
1.10.2 May 30, 2025
1.10.1 May 14, 2025
1.10.0 Apr 29, 2025
1.9.1 Apr 28, 2025
1.9.0 Apr 23, 2025
1.8.0 Mar 14, 2025
1.7.2 Feb 25, 2025
1.7.1 Feb 19, 2025
1.7.0 Jan 30, 2025
1.6.0 Jan 22, 2025
1.5.4 Jan 10, 2025
1.5.3 Jan 07, 2025
1.5.2 Dec 13, 2024
1.5.1 Dec 05, 2024
1.5.0 Nov 27, 2024
1.4.3 Nov 16, 2024
1.4.2 Oct 22, 2024
1.4.0 Oct 09, 2024
1.4.0b5 Oct 09, 2024
1.4.0b4 Oct 08, 2024
1.4.0b3 Oct 05, 2024
1.4.0b2 Sep 23, 2024
1.4.0b1 Sep 04, 2024
1.3.0 Aug 08, 2024
1.2.0 Jul 31, 2024
1.1.1 Jul 22, 2024
1.1.0 Jul 12, 2024
1.0.2 Jun 25, 2024
1.0.1 Jun 06, 2024
0.17.0 May 29, 2024
0.16.4 May 17, 2024
0.16.3 May 13, 2024
0.16.2 May 10, 2024
0.16.1 May 03, 2024
0.16.0 Apr 25, 2024
0.15.1 Apr 08, 2024
0.15.0 Apr 02, 2024
0.14.0 Mar 25, 2024
0.13.0 Mar 19, 2024
0.12.0 Mar 09, 2024
0.11.0 Mar 06, 2024
0.10.1 Feb 22, 2024
0.10.0 Feb 10, 2024
0.9.0 Feb 06, 2024
0.8.1 Jan 19, 2024
0.8.0 Dec 22, 2023
0.7.3 Dec 14, 2023
0.7.2 Dec 13, 2023
0.7.1 Dec 05, 2023
0.7.0 Oct 31, 2023
0.7.0b2 Oct 31, 2023
0.7.0b0 Oct 17, 2023
0.6.1 Oct 16, 2023
0.6.0 Oct 05, 2023
0.6.0b2 Sep 29, 2023
0.6.0b1 Sep 27, 2023
0.6.0b0 Sep 19, 2023
0.5.3 Sep 28, 2023
0.5.2 Sep 26, 2023
0.5.1 Sep 19, 2023
0.5.0 Aug 23, 2023
0.4.0 Aug 10, 2023
0.3.0 Jul 26, 2023
0.2.10 Jul 17, 2023
0.2.9 Jul 12, 2023
0.2.8 Jul 10, 2023
0.2.7 Jun 14, 2023
0.2.6 Jun 07, 2023
0.2.5 May 16, 2023
0.2.4 May 11, 2023
0.2.3 May 10, 2023
0.2.2 May 09, 2023
0.2.1 May 08, 2023
0.2.0 May 05, 2023
0.1.4 Apr 27, 2023
0.1.3 Apr 15, 2023
0.1.2 Apr 13, 2023
0.1.2b1 Apr 13, 2023
0.1.1 Apr 13, 2023
0.1.0 Apr 12, 2023
0.0.10 Apr 11, 2023
0.0.9 Apr 11, 2023
0.0.8 Apr 06, 2023
0.0.7 Apr 04, 2023
0.0.6 Apr 03, 2023
0.0.6b10 Apr 04, 2023
0.0.5 Mar 29, 2023
0.0.4 Mar 22, 2023
0.0.3 Mar 22, 2023
0.0.2 Mar 16, 2023
0.0.1 Mar 09, 2023

Wheel compatibility matrix

Platform Python 3
any

Files in release

Extras: None
Dependencies:
fsspec
httpx (>=0.24.1)
huggingface-hub (<2.0,>=0.19.3)
packaging
typing-extensions (~=4.0)
websockets (<16.0,>=13.0)