gradio icon indicating copy to clipboard operation
gradio copied to clipboard

CURL/requests documentation to swagger docs

Open ryanshrott opened this issue 9 months ago • 5 comments

How do I call the API with CURL in postman or requests module? Can someone please provide an example with documentation?

If this isn't possible, why not?

I used to be able to do it a year ago.

from gradio_client import Client

client = Client("Property-ca/photos") result = client.predict( mls_number="w5633330", photo_base_url="/public/images/listings/optimized/w5633330/mls/", number_of_images=5, version=2, api_name="/lambda" ) print(result)

ryanshrott avatar May 07 '24 21:05 ryanshrott

We will be adding documentation around this shortly. Thank you for creating an issue.

It is still possibly but it is a little more complex now. We won't be adding the documentation to the swagger docs but we will be adding it to the "Use via API" page.

pngwn avatar May 07 '24 21:05 pngwn

@pngwn thank you. Adding to the "Use via API" docs is perfect. Do you know the timeline on that? Will it be in the next release?

ryanshrott avatar May 17 '24 13:05 ryanshrott

It won't be added to the Swagger, so what about Apidog? I am currently using these two.

satokenta940 avatar May 27 '24 07:05 satokenta940

I was hoping it would be added to "View via API" button, just like we used to have these Python requests module, which is basically like curl requests.

ryanshrott avatar May 27 '24 12:05 ryanshrott

Yes, it will.

pngwn avatar May 27 '24 13:05 pngwn

We will be adding documentation around this shortly. Thank you for creating an issue.

It is still possibly but it is a little more complex now. We won't be adding the documentation to the swagger docs but we will be adding it to the "Use via API" page.

any timeline as to when CURL documentation will be added? I have something working thanks to this blogpost https://www.freddyboulton.com/blog/gradio-curl from @freddyaboulton . But there's still some things missing that I would like to do (for example authentication either from a private space or a password protected gradio app). I'm trying to call the API from a swift app so the python/js wont work for my usecase

EDIT---- In case anyone else finds this useful in the meantime, one just needs to add -H "Authorization: Bearer $TOKEN" to the curl request for any private space where $TOKEN is the access token you generate on https://huggingface.co/settings/tokens

For example in the blog from freddy

curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" -d '{"data": [3]}' http://127.0.0.1:7860/call/predict

pablovela5620 avatar May 31 '24 20:05 pablovela5620

I'm hoping soon as well! I miss curl requests :)

ryanshrott avatar May 31 '24 20:05 ryanshrott