# Request to Serverless Inference API failed with 400 status code

**URL:** <https://discuss.huggingface.co/t/request-to-serverless-inference-api-failed-with-400-status-code/143956>\
**Category:** Inference Endpoints on the Hub\
**Created:** [March 4, 2025, 8:29am UTC](https://discuss.huggingface.co/t/request-to-serverless-inference-api-failed-with-400-status-code/143956 "2025-03-04T08:29:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![LinYouyIFAD](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/linyouyifad/32/41606_2.png) [@LinYouyIFAD](https://discuss.huggingface.co/u/LinYouyIFAD)\
**Post date:** [March 4, 2025, 8:29am UTC](https://discuss.huggingface.co/t/request-to-serverless-inference-api-failed-with-400-status-code/143956/1 "2025-03-04T08:29:45Z")

</div>

I’m consistently encountering issues with the HuggingFace Serverless API, specifically with the hf-inference provider. When running the sample code on the HuggingFace serverless deployment page, I receive the following error:

```auto
openai.BadRequestError: Error code: 400 - {'error': 'Not allowed to request v1/chat/completions for provider hf-inference'}

```

I tried following models, all with the same status code:

- meta-llama/Llama-3.3-70B-Instruct
- deepseek-ai/DeepSeek-R1-Distill-Qwen-32B
- deepseek-ai/DeepSeek-R1-Distill-Llama-70B

Does anyone have any ideas or suggestions on how to resolve this 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:** [March 4, 2025, 8:56am UTC](https://discuss.huggingface.co/t/request-to-serverless-inference-api-failed-with-400-status-code/143956/2 "2025-03-04T08:56:38Z")

</div>

Same here, some posts on Hub, and some posts on HF Discord.

> [@Request failed: 500](https://discuss.huggingface.co/t/request-failed-500/138871):
>
> Just started doing some inference task through the API yesterday it worked quite fine today am getting: Request failed: 500 {“error”: “Model too busy, unable to get response in less than 60 second(s)”} although it keeps trying again but super slow - is there any issue with HF servers or something? thanks, Ed HF\_API\_URL = “[https://api-inference.huggingface.co/models/deepseek-ai/DeepSeek-R1-Distill-Qwen](https://api-inference.huggingface.co/models/deepseek-ai/DeepSeek-R1-Distill-Qwen) 32B” headers = { “Authorization”: f"Bearer {HF\_TOKEN}", “Content-Type”: “application/j…

---

<div class="post-metadata">

**Author:** ![JenniferCZuber](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/jenniferczuber/32/42464_2.png) [@JenniferCZuber](https://discuss.huggingface.co/u/JenniferCZuber)\
**Post date:** [March 4, 2025, 9:34am UTC](https://discuss.huggingface.co/t/request-to-serverless-inference-api-failed-with-400-status-code/143956/3 "2025-03-04T09:34:34Z")

</div>

It looks like you’re encountering a 400 Bad Request error when trying to access the Serverless Inference API. This usually happens due to incorrect input, missing parameters, or issues with the API request format. I’d recommend double-checking the request payload, headers, and any required parameters. Also, ensure the API endpoint you’re hitting is correct and the authorization tokens, if any, are valid. Let me know if you’d like help troubleshooting further! [Read more](https://somyatrans.wordpress.com/2024/11/28/top-insights-of-arabic-translation-for-business-growth-in-2024/)

---

<div class="post-metadata">

**Author:** ![Cyfutureai](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/cyfutureai/32/51075_2.png) [@Cyfutureai](https://discuss.huggingface.co/u/Cyfutureai)\
**Post date:** [July 28, 2025, 9:58am UTC](https://discuss.huggingface.co/t/request-to-serverless-inference-api-failed-with-400-status-code/143956/4 "2025-07-28T09:58:51Z")

</div>

> [@LinYouyIFAD](#):
>
> I’m consistently encountering issues with the HuggingFace Serverless API, specifically with the hf-inference provider. When running the sample code on the HuggingFace serverless deployment page, I receive the following error:
> 
> ```auto
> openai.BadRequestError: Error code: 400 - {'error': 'Not allowed to request v1/chat/completions for provider hf-inference'}
> 
> ```
> 
> I tried following models, all with the same status code:
> 
> - meta-llama/Llama-3.3-70B-Instruct
> - deepseek-ai/DeepSeek-R1-Distill-Qwen-32B
> - deepseek-ai/DeepSeek-R1-Distill-Llama-70B
> 
> Does anyone have any ideas or suggestions on how to resolve this issue?

You’re not alone—this seems to be a common issue when using the HuggingFace Serverless API via the `hf-inference` provider. The error:

javascript

CopyEdit

```auto
openai.BadRequestError: Error code: 400 - {'error': 'Not allowed to request v1/chat/completions for provider hf-inference'}

```

usually indicates a mismatch between the API endpoint you’re hitting (`v1/chat/completions`, which is typically used with OpenAI-compatible providers) and the capabilities or expected format for the `hf-inference` provider.

The `hf-inference` provider doesn’t support the OpenAI-compatible chat endpoint (`v1/chat/completions`) directly. Instead, it expects payloads specific to Hugging Face’s inference API. You’ll need to adapt your code to match Hugging Face’s format or use an OpenAI-compatible provider that supports the `/v1/chat/completions` endpoint properly.

If you’re looking for a smooth, OpenAI-compatible experience with models like LLaMA or DeepSeek, you might want to try **Cyfuture AI**. They offer OpenAI-compatible APIs for several high-performing open-source models (like LLaMA 3 and DeepSeek) and can be a great drop-in alternative if you’re running into provider limitations with Hugging Face.

Let me know if you need help modifying your code for Hugging Face or switching providers—happy to share examples.
