HF Inference Endpoints Error 429

HF Inference Endpoints
I’m trying to use Hugging Face Inference Endpoints with the following code:

from huggingface_hub import get_inference_endpoint

endpoint_name = 'my-endpoint-name'
endpoint = get_inference_endpoint(endpoint_name, token=self.hf_token)
endpoint.resume()
endpoint.wait()
client = endpoint.client

client.base_url = endpoint.url

res = client.post(json={"inputs": url})

But I get this error:
“Invalid user token”

I’ve double-checked that self.hf_token is copied correctly from my Hugging Face account, and it has all necessary permissions (API access and Inference endpoint usage).

Additionally, when I try running:
huggingface-cli login
I also get an error (it doesn’t let me log in).

Has anyone encountered this before?
Is there something else I need to set up, or any known issues with inference tokens?

Thank you for any help!

1 Like

Judging from the error message, it is possible that the token is really invalid. Or perhaps the necessary permissions have not been granted to the token…?

Mine is just a READ token.

from huggingface_hub import get_inference_endpoint
url = "https://huggingface.co/"
endpoint_name = 'Qwen/QwQ-32B'
HF_TOKEN = "hf_my_pro_token"
try:
    endpoint = get_inference_endpoint(endpoint_name, token=HF_TOKEN)
except Exception as e:
    print(e)
# 404 Client Error: Not Found for url: https://api.endpoints.huggingface.cloud/v2/endpoint/John6666/Qwen/QwQ-32B (Request ID:

HF_TOKEN = "foobar"
endpoint = get_inference_endpoint(endpoint_name, token=HF_TOKEN)
#     raise HTTPError(error_message, request=e.request, response=e.response) from e
# requests.exceptions.HTTPError: Invalid user token.

I have checked all the required tokens and permissions for usage.

My program retrieves data from the queue and sends it for processing at the inference endpoints using API requests.

However, after running for a while, I occasionally receive an error message: “Invalid user token.”

1 Like