aibackends-python

August 9, 2026 · View on GitHub

HTTP API for the aibackends Python library.

This service sits beside the TypeScript AI Backends API in this repo. Use it when you want local GPU/CPU model tasks (llamacpp / transformers / PII) exposed over REST.

Client / TypeScript API
        │  HTTP + Bearer

aibackends-python (:8000)  →  aibackends library  →  local models

Endpoints

MethodPathLibrary task
GET/healthliveness + defaults
POST/v1/summarizesummarize
POST/v1/classifyclassify
POST/v1/redact-piiredact_pii
POST/v1/embedembed
POST/v1/extract-invoiceextract_invoice
POST/v1/chatchat completion (+ optional tools)
POST/v1/tool-call-demoLFM2.5 tool-calling demo

Interactive docs: http://localhost:8000/docs

Browser demo (via TypeScript proxy): http://localhost:3000/api/v1/aibackends-python-demo

Usage examples: examples/aibackends-python.md

Local run

cd aibackends-python
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

# Runtime extras (install aibackends from git until LFM2.5 is on PyPI)
pip install "aibackends[llamacpp,pii,transformers] @ git+https://github.com/donvito/aibackends.git"

# LiquidAI LFM2.5-2.6B GGUF (~1.6GB) — default demo model
hf download LiquidAI/LFM2.5-2.6B-GGUF \
  --include 'LFM2.5-2.6B-Q4_K_M.gguf' \
  --local-dir models

export AIBACKENDS_ACCESS_TOKEN=your-secret-api-key
export AIBACKENDS_RUNTIME=llamacpp
export AIBACKENDS_MODEL=lfm2.5-2.6b
export AIBACKENDS_MODEL_PATH=$PWD/models/LFM2.5-2.6B-Q4_K_M.gguf
# For local smoke tests without auth:
# export AIBACKENDS_SKIP_AUTH=true

uvicorn app.main:app --reload --port 8000

Example:

curl -s http://localhost:8000/v1/summarize \
  -H "Authorization: Bearer your-secret-api-key" \
  -H "Content-Type: application/json" \
  -d '{"text":"Payments failed after checkout deploy.","model":"lfm2.5-2.6b"}'

Docker Compose

From the repo root:

docker compose up aibackends-python

The service listens on port 8000. Set DEFAULT_ACCESS_TOKEN (or AIBACKENDS_ACCESS_TOKEN) in .env.

For GPU clouds, build/run the CUDA image from the Python library repo and mount or copy this app/ package, or install aibackends[api] into that image and run uvicorn the same way.

Environment

VariableDefaultPurpose
AIBACKENDS_ACCESS_TOKEN / DEFAULT_ACCESS_TOKENBearer token
AIBACKENDS_SKIP_AUTHfalseSkip auth (dev only)
AIBACKENDS_RUNTIMEllamacppDefault runtime
AIBACKENDS_MODELlfm2.5-2.6bDefault model ref
AIBACKENDS_MODEL_PATHLocal GGUF/weights path (skips HF download)
AIBACKENDS_PYTHON_PORT8000Listen port