# 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:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Smorty100](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@Smorty100](https://discuss.huggingface.co/u/Smorty100)\
**Post date:** [October 5, 2024, 12:50am UTC](https://discuss.huggingface.co/t/using-hf-spaces-via-http-request/110186/1 "2024-10-05T00:50:53Z")

</div>

I want to use a gradio space hosted on HF with a http request. I am very much aware of the super simple python, js and bash integration, however I am not working in these languages.

Is this possible, or am I stuck with having to use one of these other options?

---

<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, 1:26am UTC](https://discuss.huggingface.co/t/using-hf-spaces-via-http-request/110186/2 "2024-10-05T01:26:14Z")

</div>

I heard that curl can be used, but isn’t it more difficult than Python?  
The get/post request contents of the Python code that uses the **requests** library are mostly raw, so I think it can be used for curl as well.

> [@Can't Access Private Gradio Space API Endpoint Through Postman](https://discuss.huggingface.co/t/cant-access-private-gradio-space-api-endpoint-through-postman/72908):
>
> I am trying to access my Huggingface space through a Postman request. When I copy the exported curl command, it looks like this: curl --location 'https://MY\_SPACE\_NAME\_HERE.hf.space/--replicas/RANDOMDIGITS/' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer hf\_REST\_OF\_MY\_TOKEN\_HERE' \ --data '{"data": ["data:image/jpeg;base64,PIC\_IN\_BASE64\_HERE"]}' But when I run this request, I get: { "detail": "Method Not Allowed" } How do get this request to succeed? Also …

> **[Send Requests to Endpoints](https://huggingface.co/docs/inference-endpoints/guides/test_endpoint)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

---

<div class="post-metadata">

**Author:** ![Smorty100](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@Smorty100](https://discuss.huggingface.co/u/Smorty100)\
**Post date:** [October 5, 2024, 10:57am UTC](https://discuss.huggingface.co/t/using-hf-spaces-via-http-request/110186/3 "2024-10-05T10:57:08Z")

</div>

It is more difficult than python, but when not working in these specific languages, one must go with the slightly more difficult alternative.  
In other words, I am willing to give up ease of use to not use python.

---

<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)’ …

---

<div class="post-metadata">

**Author:** ![ajmerphull](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/ajmerphull/32/41429_2.png) [@ajmerphull](https://discuss.huggingface.co/u/ajmerphull)\
**Post date:** [February 18, 2025, 1:09pm UTC](https://discuss.huggingface.co/t/using-hf-spaces-via-http-request/110186/5 "2025-02-18T13:09:01Z")

</div>

I am also struggling with the same issue. i have created a space on HF and created a chat app which works but then i am struggling to use curl to get a response, i posted this [HuggingFaceH4/zephyr-7b-beta · Getting NULL response using curl or PHP](https://huggingface.co/HuggingFaceH4/zephyr-7b-beta/discussions/67) for help. hope a response here or on my post will help. Not sure there is anyone here who knows the solution, especially due to lack of docs and support. ☹

---

<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:** [February 18, 2025, 2:29pm UTC](https://discuss.huggingface.co/t/using-hf-spaces-via-http-request/110186/6 "2025-02-18T14:29:01Z")

</div>

There is a document for now.

> **[Querying Gradio Apps With Curl](https://www.gradio.app/main/guides/querying-gradio-apps-with-curl)**
>
> A Step-by-Step Gradio Tutorial

---

<div class="post-metadata">

**Author:** ![Yosun](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/yosun/32/46148_2.png) [@Yosun](https://discuss.huggingface.co/u/Yosun)\
**Post date:** [February 24, 2025, 7:41pm UTC](https://discuss.huggingface.co/t/using-hf-spaces-via-http-request/110186/7 "2025-02-24T19:41:06Z")

</div>

trying to get this to work for the final step of [Stable Fast 3D - a Hugging Face Space by stabilityai](https://huggingface.co/spaces/stabilityai/stable-fast-3d)

curl -N [https://stabilityai-stable-fast-3d.hf.space/call/run\_button/](https://stabilityai-stable-fast-3d.hf.space/call/run_button/)[insert event\_id]

the results seems to always be

event: error  
data: null

any insight appreciated!

---

<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:** [February 25, 2025, 3:06am UTC](https://discuss.huggingface.co/t/using-hf-spaces-via-http-request/110186/8 "2025-02-25T03:06:48Z")

</div>

If everything didn’t work, I would understand, but it seems that some of it works. It’s a strange behavior.

```py
from gradio_client import Client, handle_file

client = Client("stabilityai/stable-fast-3d")
result = client.predict( # it works.
		image=handle_file('https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png'),
		fr=0.85,
		api_name="/requires_bg_remove"
)
print(result)

result = client.predict( # it fails.
		input_image=handle_file('https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png'),
		foreground_ratio=0.85,
		remesh_option="None",
		vertex_count=-1,
		texture_size=1024,
		api_name="/run_button"
)
print(result)

```
