# 500 Internal Server Error when use AsyncInferenceClient

**URL:** <https://discuss.huggingface.co/t/500-internal-server-error-when-use-asyncinferenceclient/128792>\
**Category:** Models\
**Created:** [December 2, 2024, 7:15am UTC](https://discuss.huggingface.co/t/500-internal-server-error-when-use-asyncinferenceclient/128792 "2024-12-02T07:15:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![endlessccl](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/endlessccl/32/36480_2.png) [@endlessccl](https://discuss.huggingface.co/u/endlessccl)\
**Post date:** [December 2, 2024, 7:15am UTC](https://discuss.huggingface.co/t/500-internal-server-error-when-use-asyncinferenceclient/128792/1 "2024-12-02T07:15:45Z")

</div>

when I use AsyncInferenceClient,sometimes I recived 500 500 Internal Server Error like this:  
`aiohttp.client_exceptions.ClientResponseError: 500, message='', url='https://api-inference.huggingface.co/models/Shakker-Labs/FLUX.1-dev-LoRA-One-Click-Creative-Template'` .  
My code just like this:

```auto
from huggingface_hub import AsyncInferenceClient

API_URL = "https://api-inference.huggingface.co/models/Shakker-Labs/FLUX.1-dev-LoRA-One-Click-Creative-Template"
headers = {
    "Authorization": "Bearer hf_xxxxxxx",
    "x-use-cache": "false"
}

def query(payload):
    response = requests.post(API_URL, headers=headers, json=payload)
    return response.content

image_bytes = query({
  "inputs": "Astronaut riding a horse",
  "parameters": {
      "width": 512,
      "height": 512
  }
})
print(image_bytes)

```
