How can I call with Postman a RESTful API deployed with Gradio?

I’m following the basic Gradio interface from the Gradio documentation:

import gradio as gr

def greet(name):
    return "Hello " + name + "!"

demo = gr.Interface(fn=greet, inputs="text", outputs="text")


The interface is:

enter image description here

I believe this deploys a RESTful API, since it says “Use via API” in the footer of the interface:

How can I call that RESTful API with Postman?

Update: using the endpoint http://localhost:7861/api/predict seems to work better, but I am still trying to figure out what the name of the key is:

enter image description here

Any idea?

hi @Franck-Dernoncourt, this Curl request works for me, content type has to be Content-Type: application/json'

hello_world - a Hugging Face Space by gradio

curl --location '' \
--header 'Content-Type: application/json' \
--data '{
    "data": [
        "test data"
1 Like

Thanks @radames , that worked. I didn’t have to set enable_queue=False though. Following your curl queryy, to do the same in Postman, set the content type to application/json and use the same payload as in your answer:

{"data": ["test"]}

yes, you’re right no need to disable queue, since the api is enabled. So the REST endpoint is also enabled, I did miss you’re not posting the right Content-Type I’m glad it’s working!

1 Like