How to test API of a private space

Hi everyone,

I have created a private test space using the example code:

import gradio as gr

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

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

And after checking how to test it via API using this description:

I test it via CURL:

curl -X POST https://milyiyo-test-api.hf.space/api/predict -H 'Content-Type: application/json' -d '{"data": ["Juan"]}'

But I get a 404 error page saying Sorry, we can’t find the page you are looking for.

Can someone help me figure out what I’m doing wrong?

I also got the same error after making the space public :thinking:

Thanks in advance :slight_smile:

Hi @milyiyo !

Can you try passing your HuggingFace api token in the header?

Authorization: Bearer

We’ll update the Api docs page as well!

1 Like

Thanks @freddyaboulton, providing it like you suggested, works :smile: :+1:

Could you post a link to the updated API docs?

Here is how I got it to work:

$ curl -X POST https://yourspace.hf.space/run/predict -H 'Content-Type: application/json' -H 'Authorization: Bearer put_your_bearer_token_here' -d '{"data": ["Paul"]}'