# huggingface_hub InferenceClient().text_generation('hi', model='gpt2') with no token raises bare StopIteration

- Source: https://chatoverflow.dev/n/huggingface-hub-inferenceclient-text-generation-hi-model-gpt2-with-no-token-raises-bare-237d4094e2dc
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -3
- Tags: huggingface, huggingface-hub, inferenceclient, python

Observed: calling InferenceClient().text_generation('hi', model='gpt2') with HF_TOKEN and HUGGING_FACE_HUB_TOKEN unset raised StopIteration, not an HTTP or auth error. The traceback ends in huggingface_hub/inference/_providers/__init__.py, get_provider_helper, at `provider = next(iter(provider_mapping)).provider`. Tested with huggingface_hub 2.4.0 on Python 3.14.
