Skip to main content

A minimal Flask API server for local HuggingFace LLMs

Project description

LLM REST API

The simplest possible Python code for running local LLM inference as a REST API server (with a simple client).

This package lets you start an inference server for Hugging Face–compatible models (like LLaMA, Qwen, GPT-OSS, etc.) on your own computer or server, and make it accessible to applications via HTTP.


Installation

From PyPI (recommended):

pip install min-llm-server-client

From source:

git clone https://github.com/afshinsadeghi/min_llm_server_client.git
cd min_llm_server_client
pip install .

Usage

Starting the Server

After installation, you can launch the server with the provided CLI entrypoint:

min-llm-server --model_name meta-llama/Llama-3.3-70B-Instruct --max_new_tokens 100 --device cuda:0

Options:

  • --model_name : Hugging Face model name or local path (e.g. openai/gpt-oss-20b, meta-llama/Llama-3.3-70B-Instruct, or /path/to/model).
  • --max_new_tokens : maximum number of tokens to generate in response.
  • --device : cpu, cuda:0, cuda:1, etc.

Example (CPU run):

min-llm-server --model_name openai/gpt-oss-20b --max_new_tokens 50 --device cpu

Sending Queries

Once the server is running (default: http://127.0.0.1:5000/llm/q), you can query it with curl or Python.

Curl:

curl -X POST http://127.0.0.1:5000/llm/q \
  -H "Content-Type: application/json" \
  -d '{"query": "What is Earth?", "key": "key1"}'

Python client:

from min_llm_server_client.local_llm_inference_api_client import send_query

response = send_query("What is the capital of France?", user="user1", key="key1")
print(response)

Performance notes

  • Running LLaMA 3.1 8B:
    • Intel CPU → ~30 seconds per request, ~2.4 GB RAM
    • A100 GPU → <1 second per request, ~34 GB GPU memory, ~4.8 GB CPU RAM

Project Structure

min_llm_server_client/
├── src/
│   ├── local_llm_inference_api_client.py
│   ├── local_llm_inference_server_api.py
│   └── ...
└── README.md

License

This project is open source under the Apache 2.0 License.


Author

Afshin Sadeghi
📧 sadeghi.afshin@gmail.com
🔗 GitHub
🔗 Google Scholar
🔗 LinkedIn

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

min_llm_server_client-0.2.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

min_llm_server_client-0.2.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file min_llm_server_client-0.2.0.tar.gz.

File metadata

  • Download URL: min_llm_server_client-0.2.0.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.12

File hashes

Hashes for min_llm_server_client-0.2.0.tar.gz
Algorithm Hash digest
SHA256 4ddd7302273a61f49bc1d386b13ab6b476bd084e6c714091d06e3bcd93887204
MD5 9ecbfcafa935c77b33d4d707b5727719
BLAKE2b-256 714ed6818c24750283609b201dd8a6ae02afa9ce16034f232dc89a142e4d93ba

See more details on using hashes here.

File details

Details for the file min_llm_server_client-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for min_llm_server_client-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c90dd2d562c79314d581b76039ccb08e9e635cb8700ed1cd697a0041ca0cf52e
MD5 cc4dd072b18c1128f28ce610a583a44e
BLAKE2b-256 9194f2a40efec2b27305c07e8e2f51a2f1c99382ddd7d402045e81c5cce16105

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page