# Example Inference API (model & code ), pls

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fexample-inference-api-model-code-pls%2F160954%3E%5C
**Category:** Beginners\
**Created:** [June 27, 2025, 9:55pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fexample-inference-api-model-code-pls%2F160954 "2025-06-27T21:55:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![RaviRJoshi](https://avatars.discourse-cdn.com/v4/letter/r/e9a140/32.png) [@RaviRJoshi](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FRaviRJoshi)%5C
**Post date:** [June 27, 2025, 9:55pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fexample-inference-api-model-code-pls%2F160954%2F1 "2025-06-27T21:55:26Z")

</div>

Hello. I am an absolute beginner, and getting started with HF / Inference API. etc.  
I am trying to connect to some model and ask basic question. I have created a read access token, and am using following code to connect to gpt2. But I am getting a status code of response to 404 error.

API\_TOKEN=“hf\_hlelroqylkhxpadxguximotbpjbmxosrth”  
MODEL = “openai-community/gpt2” #tried a few others as well  
API\_URL = f"[/static-proxy?url=https%3A%2F%2Fapi-inference.huggingface.co%2Fmodels%2F%7BMODEL%7D%5D(https%3A%2F%2Fapi-inference.huggingface.co%2Fmodels%2F%257BMODEL%257D)"  
headers = { “Authorization”: f"Bearer {API\_TOKEN}"}  
prompt = “Tell me about Paris.”  
def query(payload):  
response = requests.post(API\_URL, headers=headers, json=payload)

Can someone pls help?

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [June 28, 2025, 1:20am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fexample-inference-api-model-code-pls%2F160954%2F2 "2025-06-28T01:20:42Z")

</div>

Since gpt2 does not appear to be deployed at this time, I will explain using a deployed model. Samples for Python, JavaScript, and curl can be obtained in the following manner.

1. ![iapisample1](https://us1.discourse-cdn.com/hellohellohello/original/3X/0/c/0c38a01be6e1cabeeacecde01dd7dc737d0a8199.png)
2. ![iapisample2](https://us1.discourse-cdn.com/hellohellohello/original/3X/e/e/ee4eed2559fa699199e34102ca77588b5c2d1783.png)
3. ![iapisample3](https://us1.discourse-cdn.com/hellohellohello/original/3X/4/f/4ffb9e644d7a3ddd12fc37c50392ac3d0d236a79.png)
4. ![iapisample5](https://us1.discourse-cdn.com/hellohellohello/original/3X/3/1/314ddd7c547439b5e62e0b075f7751229a698d08.png)

### Deployed models (by HF Inference API)

> **[Models available on HF Inference API – Hugging Face](https://huggingface.co/models?inference_provider=hf-inference&sort=trending)**
>
> Explore machine learning models.

### Deployed models (by all Inference Provider)

> **[Models available on all – Hugging Face](https://huggingface.co/models?inference_provider=all&sort=trending)**
>
> Explore machine learning models.

---

<div class="post-metadata">

**Author:** ![RaviRJoshi](https://avatars.discourse-cdn.com/v4/letter/r/e9a140/32.png) [@RaviRJoshi](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FRaviRJoshi)%5C
**Post date:** [June 28, 2025, 9:04am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fexample-inference-api-model-code-pls%2F160954%2F3 "2025-06-28T09:04:24Z")

</div>

Thanks John \_/\_. I am able to run chat thing.

Once I click Deploy, how does one know if it’s actually deployed? Is there a status such as ‘deployed’?  
Is it possible to ‘undeploy’ ?

Underneath ‘deploy’ is a graph of number of downloads. Is it the number deployed or the model actually downloaded?

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [June 28, 2025, 11:51am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fexample-inference-api-model-code-pls%2F160954%2F4 "2025-06-28T11:51:11Z")

</div>

Oh. Now that you mention it, that explanation is confusing.😅  
The deployment status and the Deploy button above are not related.

The `Deploy` button is just a sample of how users can deploy the model or assist with deploying it to the necessary sites.

The deployment status indicates whether the model is currently deployed in the Inference Provider. It may change if Hugging Face staff deploy it or in response to `Ask for provider support`, but it doesn’t change often. Probably.

---

<div class="post-metadata">

**Author:** ![RaviRJoshi](https://avatars.discourse-cdn.com/v4/letter/r/e9a140/32.png) [@RaviRJoshi](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FRaviRJoshi)%5C
**Post date:** [June 28, 2025, 8:29pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fexample-inference-api-model-code-pls%2F160954%2F5 "2025-06-28T20:29:53Z")

</div>

Thx again.  
When I get ‘you have exceeded monthly limits …’. Is this msg coming from HF or from inference providers?  
Also, how to find if a free tier is available from an inference provider, if this question makes sense.

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [June 28, 2025, 8:51pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fexample-inference-api-model-code-pls%2F160954%2F6 "2025-06-28T20:51:40Z")

</div>

> When I get ‘you have exceeded monthly limits …’. Is this msg coming from HF or from inference providers?

from HF. I think Inference Provider is a mechanism where HF collects requests and manages billing.

> Also, how to find if a free tier is available from an inference provider, if this question makes sense.

It’s like this. With a free account, it’s equivalent to $0.1 per month.

> [@Hugging Face Payment Error 402 & You've Exceeded Monthly Quota](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhugging-face-payment-error-402-youve-exceeded-monthly-quota%2F144968%2F20)%3A
>
> Hi @Yannael We offer pay-as-you-go billing support for PRO and Enterprise Hub users at this time - subscribe to PRO here: [Hugging Face – The AI community building the future.](https://huggingface.co/settings/billing/subscription) to receive $2 free inference credits and [more](https://huggingface.co/docs/hub/en/billing#pro-subscription). We also have some additional info about Inference Providers pricing here: [Pricing and Billing](https://huggingface.co/docs/inference-providers/en/pricing). Hope this helps!
