# Error 402 while using smolagents with a valid token

**URL:** <https://discuss.huggingface.co/t/error-402-while-using-smolagents-with-a-valid-token/152624>\
**Category:** Inference Endpoints on the Hub\
**Created:** [April 28, 2025, 10:05am UTC](https://discuss.huggingface.co/t/error-402-while-using-smolagents-with-a-valid-token/152624 "2025-04-28T10:05:40Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![AI-CC-Eric](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@AI-CC-Eric](https://discuss.huggingface.co/u/AI-CC-Eric)\
**Post date:** [April 28, 2025, 10:05am UTC](https://discuss.huggingface.co/t/error-402-while-using-smolagents-with-a-valid-token/152624/1 "2025-04-28T10:05:40Z")

</div>

Hello,

I have an entreprise hub license and was completing the agent training (well done by the way).  
I started building an agent for the final assignment and set up the token accordingly.  
Unfortunately, I always get an error 402 even if I still have some credits. Could you please support on that?

 ![inference_usage](https://us1.discourse-cdn.com/hellohellohello/original/3X/a/7/a7d47f960976bd3f3f50139c5427ea9bfb782eaa.png)

Regards  
Eric

---

<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:** [April 28, 2025, 12:53pm UTC](https://discuss.huggingface.co/t/error-402-while-using-smolagents-with-a-valid-token/152624/2 "2025-04-28T12:53:13Z")

</div>

Maybe this?

> [@Exceeded your montly...credits. But I am ENTERPRISE?](https://discuss.huggingface.co/t/exceeded-your-montly-credits-but-i-am-enterprise/150888):
>
> I have a fine-grained token, with the following enabled a the source account level: At the Enterprise level the same token shows: Enterprise Inference Providers shows: You have exceeded your monthly included credits for Inference Providers. Subscribe to PRO to get 20x more monthly included credits.

---

<div class="post-metadata">

**Author:** ![AI-CC-Eric](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@AI-CC-Eric](https://discuss.huggingface.co/u/AI-CC-Eric)\
**Post date:** [April 28, 2025, 2:39pm UTC](https://discuss.huggingface.co/t/error-402-while-using-smolagents-with-a-valid-token/152624/3 "2025-04-28T14:39:28Z")

</div>

Thanks, I tried adding the bill\_to keyword as proposed in [Pricing and Billing](https://huggingface.co/docs/inference-providers/pricing#organization-billing).

Unfortunately, I got an error message.

 ![error_message_keyword](https://us1.discourse-cdn.com/hellohellohello/original/3X/8/3/83e4ed52f2dc6c66976dc76860aa10e0188bcf56.png)

---

<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:** [April 29, 2025, 12:21am UTC](https://discuss.huggingface.co/t/error-402-while-using-smolagents-with-a-valid-token/152624/4 "2025-04-29T00:21:58Z")

</div>

Try:

```auto
pip install -U huggingface_hub

```

---

<div class="post-metadata">

**Author:** ![AI-CC-Eric](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@AI-CC-Eric](https://discuss.huggingface.co/u/AI-CC-Eric)\
**Post date:** [April 29, 2025, 6:40am UTC](https://discuss.huggingface.co/t/error-402-while-using-smolagents-with-a-valid-token/152624/5 "2025-04-29T06:40:23Z")

</div>

Hi John6666,

unfortunately, this doesn’t solve the issue.

---

<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:** [April 29, 2025, 7:04am UTC](https://discuss.huggingface.co/t/error-402-while-using-smolagents-with-a-valid-token/152624/6 "2025-04-29T07:04:47Z")

</div>

@meganariley Enterprise token issue…

---

<div class="post-metadata">

**Author:** ![meganariley](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/meganariley/32/56966_2.png) [@meganariley](https://discuss.huggingface.co/u/meganariley)\
**Post date:** [April 29, 2025, 11:24pm UTC](https://discuss.huggingface.co/t/error-402-while-using-smolagents-with-a-valid-token/152624/7 "2025-04-29T23:24:09Z")

</div>

Hi, we have some examples to set up this attribute for the JavaScript and Python InferenceClient here: [Pricing and Billing](https://huggingface.co/docs/inference-providers/pricing#organization-billing). If you’re still seeing issues, can you please share a screenshot of the code snippet?

---

<div class="post-metadata">

**Author:** ![AI-CC-Eric](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@AI-CC-Eric](https://discuss.huggingface.co/u/AI-CC-Eric)\
**Post date:** [April 30, 2025, 6:27am UTC](https://discuss.huggingface.co/t/error-402-while-using-smolagents-with-a-valid-token/152624/8 "2025-04-30T06:27:54Z")

</div>

Hi, the link you showed is the documentation I followed.  
Please find attached the code snippet (organization name is masked but declared as a regular string in the code).

 ![code_snippet](https://us1.discourse-cdn.com/hellohellohello/original/3X/3/d/3da2bc81f0cd3e606ddd08cb4b2bfcc457f40609.jpeg)
