Transformers FastAPI Kit
A small, production-oriented wrapper around Hugging Face Transformers plus a FastAPI REST service for sentiment analysis.
Install
pip install transformers-fastapi-kit[api]
The first prediction downloads the default model (distilbert-base-uncased-finetuned-sst-2-english) from Hugging Face and caches it locally.
Python usage
from transformers_fastapi_kit import SentimentModel
model = SentimentModel()
print(model.predict("This package is excellent!"))
# {'label': 'POSITIVE', 'score': 0.99...}
Use a different model with SentimentModel(model_name="..."); pass device=0 for a CUDA GPU or leave the default -1 for CPU.
Run the API
From the repository root:
pip install -e ".[api]"
uvicorn app.main:app --host 0.0.0.0 --port 8000
Interactive Swagger UI: http://localhost:8000/docs
curl -X POST http://localhost:8000/predict \\
-H 'Content-Type: application/json' \\
-d '{"text":"I love this API"}'
Endpoints: GET /health, POST /predict, and the generated OpenAPI schema at /openapi.json.
Development
pip install -e ".[api,dev]"
pytest
python -m build
python -m twine check dist/*
License
MIT
Metadata
Release files for transformers-fastapi-kit 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| transformers_fastapi_kit-0.1.0.tar.gz | 3.6 kB | Without provenance | Details for transformers_fastapi_kit-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| transformers_fastapi_kit-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for transformers_fastapi_kit-0.1.0-py3-none-any.whl |
Total release size: 7.1 kB
Release files / transformers_fastapi_kit-0.1.0.tar.gz
| Download URL | transformers_fastapi_kit-0.1.0.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f913244d9c891ad74eaf2d1fdb1539e30895a98b5e41d9c4f0a7e50cb5eda071
|
|
BLAKE2b-256 checksum How to use checksums |
49d9a009c5d69f7270063030d02a07f376cc931e3ce7e98aa5998cdba9bec037
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / transformers_fastapi_kit-0.1.0-py3-none-any.whl
| Download URL | transformers_fastapi_kit-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
04e1ad20b199bfb2b8972d5718f64c661400d59b5cab8fc01c268bc7fb0437b5
|
|
BLAKE2b-256 checksum How to use checksums |
3df0612ce39ed0529bc89555d578539b366509289127e96782a735b04d2285ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Security for transformers-fastapi-kit 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.