One model, any hardware.
An OpenAI-compatible server that runs the same model on CPU, Apple Metal, NVIDIA CUDA, AMD ROCm or an NPU, and decides for every request whether it runs locally or in the cloud, by privacy, latency and cost.
uvx --from git+https://github.com/Hassan-Memon/openinfer openinfer serve
Runs with zero API keys. With no models configured it answers from a deterministic echo backend, so the whole API works on the first try.
Why it exists
Inference today means picking one vendor's GPU, one vendor's API, and hoping the bill is reasonable. OpenInfer puts a policy layer in front of all of them.
No hardware lock-in
One GGUF file runs through llama.cpp on CPU, Metal, CUDA or ROCm. Ollama and vLLM plug in over HTTP. A cloud API is just one more backend.
Private stays private
Tag a request private and only local backends are eligible. If no local backend can serve it, the request fails instead of falling through to the cloud.
Cost you can see
Every request records tokens, cost, latency and time to first token. Read it back from /v1/ledger, Prometheus /metrics or the bench command.
Your SDK already works
The API is OpenAI's wire format. Point the OpenAI SDK, LangChain or curl at it and change only the base URL.
Free tiers, made reliable
Alias chains retry with exponential backoff and fall through Groq, Gemini, OpenRouter, Ollama and llama.cpp in the order you choose.
Policy is a file
Aliases, privacy rules, cost and latency ceilings live in openinfer.yaml. Operators change behaviour without a deploy, and auditors can read it.
Router playground
This runs the router's selection rules in your browser, using the default alias chains from the repo's openinfer.yaml. Choose a request and switch backends off to see the fallback and the privacy rule at work.
Measured, not claimed
Output of openinfer bench on a Windows 11 laptop, CPU only, with Ollama running locally. No GPU.
| Backend | Model | Where | Time to first token, p50 | Generated tokens/s | Total p50 | USD per 1M output tokens |
|---|---|---|---|---|---|---|
| ollama | deepseek-r1:1.5b | local | 380 ms | 16.0 | 3,376 ms | 0.00 |
| echo | echo | local | 0.1 ms | 171,059 | 0.2 ms | 0.00 |
The echo row is the test backend and shows only server overhead. Run openinfer bench on your own machine to get your numbers.
How a request flows
Clients speak OpenAI. The router picks a backend. The ledger records what happened.
Clients
- OpenAI SDK
- LangChain
- curl, any HTTP client
OpenInfer
- /v1/chat/completions, SSE streaming
- /v1/embeddings, /v1/models
- Router: aliases, privacy, cost, latency, fallback
- Ledger and /metrics
Backends
- Local: llama.cpp, Ollama, vLLM
- Cloud: Groq, Gemini, OpenRouter, OpenAI
- Echo for tests and demos
from openai import OpenAI
client = OpenAI(base_url="http://localhost:8000/v1", api_key="unused")
client.chat.completions.create(
model="private",
messages=[{"role": "user", "content": "Summarise this patient note"}],
)
Read the engineering
The repo is written to be learned from: decision records for every major choice, and a short course on the concepts behind it.
Decision records
Why the OpenAI wire format, why policy as YAML, why llama.cpp first, why privacy fails closed.
Learning track
Architecture walkthrough, system design trade-offs, quantization, accelerators and cost accounting.
Positioning
How it compares with NVIDIA NIM, Apple on-device models, the OpenAI API, Ollama, LiteLLM and vLLM.