# Using HF spaces via http request?

**URL:** <https://discuss.huggingface.co/t/using-hf-spaces-via-http-request/110186>\
**Category:** Beginners\
**Created:** [October 5, 2024, 12:50am UTC](https://discuss.huggingface.co/t/using-hf-spaces-via-http-request/110186 "2024-10-05T00:50:53Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [October 5, 2024, 11:16am UTC](https://discuss.huggingface.co/t/using-hf-spaces-via-http-request/110186/4 "2024-10-05T11:16:24Z")

</div>

I see. If you want to use it in a compiled language, for example, you can handle it in a more complicated way.

For HF, the easiest way is to use InferenceClient with Python or JS, but if that’s not possible, the next best thing is an API that returns JSON.  
I heard that everyone used this before InferenceClient was developed, so there should be a lot that can be done, but because of that history, there is a lot of pre-2023 information. Well, it’s still in use inside old Gradio and so on, and it should work.

> [@Hf.space/run/predict Data Aggregate howto?](https://discuss.huggingface.co/t/hf-space-run-predict-data-aggregate-howto/30665):
>
> Hi, I understand the syntax curl -X POST -H 'Content-type: application/json' --data '{ "data": ["Jill"] }' https://USER\_NAME-SPACE\_NAME.hf.space/run/predict and trying it out on a space with a simple text input e.g., curl -X POST -H 'Content-type: application/json' --data '{ "data": ["Jill"] }' https://tomsoderlund-rest-api-with-gradio.hf.space/run/predict returns a nice {"data":["Hello Jill!"],"is\_generating":false,"duration":0.00015020370483398438,"average\_duration":0.00018148869276046753}…

> [@Spaces POST: response \[413\] 'request entity too large'](https://discuss.huggingface.co/t/spaces-post-response-413-request-entity-too-large/26723):
>
> I’ve successfully used the following snippet to call the classifier specified below, with small images. When using the image such as the below (\< 1MB), I see 413 errors. From other forum posts I believe the file size is not the real problem here; what might I be missing? import requests import gradio as gr from IPython.display import Image from IPython.core.display import HTML image\_url = ‘[https://i.natgeofe.com/n/548467d8-c5f1-4551-9f58-6817a8d2c45e/NationalGeographic\_2572187\_square.jpg](https://i.natgeofe.com/n/548467d8-c5f1-4551-9f58-6817a8d2c45e/NationalGeographic_2572187_square.jpg)’ …

---

_[View the full topic](https://discuss.huggingface.co/t/using-hf-spaces-via-http-request/110186)._
