text-generation
Hugging Face Text Generation Python Client
What it is and what it does
Text Generation is a Python client library for querying large language models hosted on Hugging Face's managed inference infrastructure. It wraps HTTP calls to text-generation-inference instances running on Hugging Face Inference Endpoints or the Hub, exposing both synchronous and asynchronous interfaces for generating text completions. The library handles request serialization via pydantic, HTTP communication through aiohttp, and model discovery via huggingface-hub.
You use it by instantiating a Client (or AsyncClient) with an endpoint URL, then calling generate() or generate_stream() to send prompts and receive completions. The library supports advanced generation parameters—sampling, repetition penalties, stop sequences, grammar constraints, and token-level details—and can stream tokens as they are produced rather than waiting for the full response.
Use it for:
- Query a deployed Hugging Face Inference Endpoint model from Python without managing the underlying HTTP protocol.
- Stream text generation tokens in real time for interactive applications or live UI updates.
- Build async-first applications that query multiple models concurrently without blocking.
- Prototype language model applications against Hugging Face's managed inference without running local infrastructure.
- Access generation metadata (finish reason, token logprobs, top-k alternatives) for analysis or debugging.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a Python client to query text generation models hosted on Hugging Face Inference Endpoints or the Hugging Face Hub, with support for both synchronous and asynchronous generation and token streaming.
No—do not install. The package is abandoned (archived repository, no commits since 2026-03-21), carries four known vulnerabilities, and receives no maintenance. While the install friction is low and the license is permissive, the lack of security patches and active support makes it unsuitable for production use. Consider using the official Hugging Face Hub library or InferenceClient from huggingface-hub directly instead.
Install
text-generation on PyPI
pip
pip install text-generationuv
uv add text-generationpoetry
poetry add text-generationInstalling text-generation
Before you install
Installation is straightforward with low friction—a pure Python wheel with three runtime dependencies (pydantic, aiohttp, huggingface-hub). However, the repository is archived and the package is abandoned; the last commit was 2026-03-21 and no maintenance is active, so security patches and compatibility updates are unlikely.
License in practice
Licensed under Apache-2.0 (permissive), so you can use, modify, and distribute the package freely in commercial and private projects without restriction.
Quickstart
pip install text-generation
from text_generation import Client
client = Client("https://YOUR_ENDPOINT.endpoints.huggingface.cloud")
response = client.generate("Why is the sky blue?")
print(response.generated_text)
Requires a running text-generation-inference instance or an active Hugging Face Inference Endpoint URL to connect to.
Verify before relying
- Whether the package still works reliably with current Hugging Face Inference Endpoint APIs, given the abandoned status.
- Compatibility of the four known vulnerabilities (GHSA-j7x9-7j54-2v3h, GHSA-qq99-p57r-g3v7, PYSEC-2026-1965, PYSEC-2026-1966) with your use case and whether they are exploitable in your deployment context.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (<4.0,>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — pydantic, aiohttp, huggingface-hub |
| Maintenance | abandoned — 875 days since the last release |
| Last repo commit | (repository archived) |
| First released | |
| Downloads | 173,500/month — #10,306 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | 4 — GHSA-j7x9-7j54-2v3h, GHSA-qq99-p57r-g3v7, PYSEC-2026-1965, PYSEC-2026-1966 |
Evidence: text_generation-0.7.0-py3-none-any.whl
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
mlx-lmMLX LM loads, generates text with, fine-tunes,…
permissive · top 5,000 on PyPI
ollamaProvides a Python client to interact with…
permissive · top 5,000 on PyPI
spacesProvides utilities for working with Hugging…
permissive · top 15,000 on PyPI
langchain-huggingfaceConnects Hugging Face models and embeddings to…
permissive · top 5,000 on PyPI
hfA command-line interface for interacting with…
permissive · top 15,000 on PyPI
transformers-stream-generatorModifies Hugging Face Transformers…
permissive · top 15,000 on PyPI
optimum-onnxExports Hugging Face transformer models to ONNX…
permissive · top 15,000 on PyPI
pyspark-huggingfaceRegisters a Spark data source that reads…
permissive · top 5,000 on PyPI
llama-index-embeddings-huggingfaceIntegrates Hugging Face embedding models with…
permissive · top 15,000 on PyPI