Skip to main content

jbr-inference

A local inference service that exposes one OpenAI-compatible API and routes each model to its own backend: a GPU backend (llama.cpp server, CUDA) or an NPU backend (OpenVINO), plus an in-memory fake backend for development and tests.

Why

Running several local models on different accelerators usually means one server and one client convention per backend. jbr-inference puts a single HTTP contract in front of them: a registry maps each model id to a backend, a router dispatches the request, and a backend that is not running answers 503 instead of crashing the service. Mixed GPU and NPU use is not a coded feature: it follows from the registry, each backend staying in its own process and its own virtual environment.

Install

python -m venv .venv && . .venv/bin/activate
pip install jbr-inference

The base package only needs FastAPI, Uvicorn, HTTPX and Pydantic. The real backends are optional extras (jbr-inference[gpu], jbr-inference[npu]) and are meant to live in separate virtual environments.

Quick start

Runs as-is after the install above, without cloning this repository:

# Start the service with the built-in fake backend (no GPU, no NPU, no model weights)
python -m uvicorn jbr_inference.serving.app:app --host 127.0.0.1 --port 8000 &
sleep 3

# List the registered models
curl -s http://127.0.0.1:8000/v1/models

# Chat through the fake backend (deterministic answer, no network access)
curl -s http://127.0.0.1:8000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model": "fake-chat-7b", "messages": [{"role": "user", "content": "hello"}]}'

kill $!

The registry also lists GPU and NPU models: they are routable, but answer 503 backend_unavailable until the matching backend server is running.

Architecture

  • jbr_inference/serving/: the common contract (API, router, error envelope) and the fake backend.
  • jbr_inference/models/: the model-to-backend registry (registry.toml) and quantization policies.
  • jbr_inference/backends/gpu/: adapter and lifecycle manager for a local llama.cpp server.
  • jbr_inference/backends/npu/: OpenVINO service for a static-shape encoder, and its conversion script.
  • jbr_inference/bench/: a benchmark harness that calls the common API, never a backend directly.

The service listens on loopback only. The management API (/admin/*) is only active when JBR_INFERENCE_ENABLE_ADMIN=1: otherwise its router is not mounted, and a request to /admin/* without a loopback Origin header is refused with 403 (with one, it gets a plain 404). When enabled, every /admin/* request still has to carry a loopback Origin header.

Measurements

One small run drives the common API against a real GPU model and a real NPU model, with invented prompts and texts (3 requests each, 0 errors); the two figures measure different tasks and are not comparable with each other (details).

Limitations

  • The GPU and NPU backends were exercised on a single machine (an NVIDIA GPU under WSL2, an Intel NPU through a native Windows OpenVINO service). Other hardware and operating systems are untested.
  • The NPU backend needs static input shapes (a fixed sequence length chosen at export time).
  • The usage token counters returned by the real backends are zero: they are not wired yet.
  • The GPU throughput in the benchmark is an estimate (about 4 characters per token), not a tokenizer count.
  • Model weights are never shipped: they are fetched by the user, as described in the backend READMEs of the source tree.

Language and contributions

Everything in this repository is in English, except recorded data: French bench samples and NER test inputs (the NER model is French-language) and recorded outputs reproduced verbatim in the bench proofs and the NPU spike notes.

This is a mirror repository: contributions are reviewed and ported by hand. Issues are welcome; pull requests are read but not merged as such, and a change that is accepted lands in a later release. Security reports: see SECURITY.md.

License

Apache License 2.0, see LICENSE and NOTICE.

Metadata

Release files for jbr-inference 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jbr-inference 0.1.2
File Size Uploaded Provenance Actions
jbr_inference-0.1.2.tar.gz 270.3 kB With provenance Details for jbr_inference-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for jbr-inference 0.1.2
File Interpreter ABI Platform Actions
jbr_inference-0.1.2-py3-none-any.whl Python 3 none any Details for jbr_inference-0.1.2-py3-none-any.whl

Total release size: 336.9 kB

Release files / jbr_inference-0.1.2.tar.gz

Download URL jbr_inference-0.1.2.tar.gz
Size 270.3 kB
Tags Source
SHA-256 checksum
How to use checksums
3b8d57db4ee2a6ae830c922db182223f50ffa90742a1a6eec19c065f1fb6b6a6
BLAKE2b-256 checksum
How to use checksums
c9873747345fe9b748eeabe8bfc609b6400fb7eb9af2ec0c50ed8deb95a4af55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.

Transparency log

Release files / jbr_inference-0.1.2-py3-none-any.whl

Download URL jbr_inference-0.1.2-py3-none-any.whl
Size 66.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2e961f9898d574876df769cf26f279cbbde049f20254cd2847542903cd11d4d8
BLAKE2b-256 checksum
How to use checksums
1d6cc15566f8ba123c2fc138db5a44512a6aa2ac1995276b852b9db5092b7451
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.

Transparency log

Security for jbr-inference 0.1.2

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for jbr_inference-0.1.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page